@aedart/vuepress-utils
Version:
A few utilities for Vuepress.
40 lines (35 loc) • 1.65 kB
JavaScript
/**
* @aedart/vuepress-utils
*
* BSD-3-Clause, Copyright (c) 2023-present Alin Eugen Deac <aedart@gmail.com>.
*/
;
var utils = require('@vuepress/utils');
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
const __dirname$1 = utils.getDirname((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugins.cjs', document.baseURI).href)));
/**
* Formats the last updated timestamp according to given format
*
* @param {string | undefined} [format='yyyy-MM-dd HH:mm:ss ZZZZ']
* @param {import('luxon/src/datetime').DateTimeJSOptions | undefined} [options={}]
*
* @returns {import('@vuepress/core').Plugin}
*/
const lastUpdatedPlugin = ({ format = 'yyyy-MM-dd HH:mm:ss ZZZZ', options = {} } = {}) => {
return {
name: 'last-updated-plugin',
extendsPage: (page) => {
// @ts-expect-error: TS2339 because strange definition of PageData from vuepress
page.data.lastUpdatedDateFormat = format;
// @ts-expect-error: TS2339 because strange definition of PageData from vuepress
page.data.lastUpdatedDateOptions = options;
},
alias: {
'@theme/PageMeta.vue': utils.path.resolve(__dirname$1, '../components/plugins/LastUpdatedPlugin.vue' // In "dist" directory
),
}
};
};
exports.lastUpdatedPlugin = lastUpdatedPlugin;
module.exports = Object.assign(exports.default, exports);
//# sourceMappingURL=plugins.cjs.map