UNPKG

@aedart/vuepress-utils

Version:

A few utilities for Vuepress.

36 lines (31 loc) 1.19 kB
import { getDirname, path } from '@vuepress/utils'; /** * @aedart/vuepress-utils * * BSD-3-Clause, Copyright (c) 2023-present Alin Eugen Deac <aedart@gmail.com>. */ const __dirname = getDirname(import.meta.url); /** * 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': path.resolve(__dirname, '../components/plugins/LastUpdatedPlugin.vue' // In "dist" directory ), } }; }; export { lastUpdatedPlugin };