UNPKG

@nolebase/vitepress-plugin-page-properties

Version:

A VitePress plugin that renders frontmatter as page properties, and makes them editable.

95 lines (90 loc) 3.71 kB
import { Plugin } from 'vite'; interface Context { helpers: { /** * A helper function to help to determine whether the passed string parameter equals the * current transforming module ID with normalization of paths capabilities and * cross platform / OS compatibilities. * * @param equalsWith - String to equal with * @returns boolean */ idEquals: (equalsWith: string) => boolean; /** * A helper function to help to determine whether the passed string parameter startsWith the * current transforming module ID with normalization of paths capabilities and * cross platform / OS compatibilities. * * @param startsWith - String to start with * @returns boolean */ idStartsWith: (startsWith: string) => boolean; /** * A helper function to help to determine whether the passed string parameter endsWith the * current transforming module ID with normalization of paths capabilities and * cross platform / OS compatibilities. * * @param endsWith - String to end with * @returns boolean */ idEndsWith: (endsWith: string) => boolean; /** * A helper function to help to determine whether the passed first path parameter * equals the second passed string with normalization of paths capabilities and * cross platform / OS compatibilities. * * @param path - Path to be compared with * @param equalsWith - String to equal with * @returns boolean */ pathEquals: (path: string, equalsWith: string) => boolean; /** * A helper function to help to determine whether the passed first path parameter * startsWith the second passed string with normalization of paths capabilities and * cross platform / OS compatibilities. * * @param path - Path to be compared with * @param startsWith - String to start with * @returns boolean */ pathStartsWith: (path: string, startsWith: string) => boolean; /** * A helper function to help to determine whether the passed first path parameter * endsWith the second passed string with normalization of paths capabilities and * cross platform / OS compatibilities. * * @param path - Path to be compared with * @param endsWith - String to end with * @returns boolean */ pathEndsWith: (path: string, endsWith: string) => boolean; }; } interface PagePropertiesMarkdownSectionOptions { /** * The list of file names to exclude from the transformation * * @default ['index.md'] */ excludes?: string[]; /** * The function to exclude the file from the transformation * * @param id - the current transforming module ID (comes from vite when transform hook is called) * @param context - the context object, contains several helper functions * @returns boolean * @default () => false */ exclude?: (id: string, context: Context) => boolean; } declare function PagePropertiesMarkdownSection(options?: PagePropertiesMarkdownSectionOptions): Plugin; interface LanguageHandler { regex: RegExp; wordsPerMinute: number; } interface ReadingTimeStats { readingTime: number; wordsCount: number; } declare function PageProperties(): Plugin; export { type Context, type LanguageHandler, PageProperties, PagePropertiesMarkdownSection, type PagePropertiesMarkdownSectionOptions, type ReadingTimeStats as ReadingTimeResult };