feat(pages): add LastUpdateAuthor & LastUpdateTime & editUrl (#10032)

Co-authored-by: OzakIOne <OzakIOne@users.noreply.github.com>
Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
ozaki 2024-04-16 11:23:00 +02:00 committed by GitHub
parent e4ecffe418
commit d1590e37ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 254 additions and 8 deletions

View file

@ -8,6 +8,7 @@
declare module '@docusaurus/plugin-content-pages' {
import type {MDXOptions} from '@docusaurus/mdx-loader';
import type {LoadContext, Plugin} from '@docusaurus/types';
import type {FrontMatterLastUpdate, LastUpdateData} from '@docusaurus/utils';
export type Assets = {
image?: string;
@ -20,6 +21,10 @@ declare module '@docusaurus/plugin-content-pages' {
include: string[];
exclude: string[];
mdxPageComponent: string;
showLastUpdateTime: boolean;
showLastUpdateAuthor: boolean;
editUrl?: string | EditUrlFunction;
editLocalizedFiles?: boolean;
};
export type Options = Partial<PluginOptions>;
@ -35,6 +40,7 @@ declare module '@docusaurus/plugin-content-pages' {
readonly toc_max_heading_level?: number;
readonly draft?: boolean;
readonly unlisted?: boolean;
readonly last_update?: FrontMatterLastUpdate;
};
export type JSXPageMetadata = {
@ -43,16 +49,31 @@ declare module '@docusaurus/plugin-content-pages' {
source: string;
};
export type MDXPageMetadata = {
export type MDXPageMetadata = LastUpdateData & {
type: 'mdx';
permalink: string;
source: string;
frontMatter: PageFrontMatter & {[key: string]: unknown};
editUrl?: string;
title?: string;
description?: string;
unlisted: boolean;
};
export type EditUrlFunction = (editUrlParams: {
/**
* The root content directory containing this post file, relative to the
* site path. Usually the same as `options.path` but can be localized
*/
pagesDirPath: string;
/** Path to this pages file, relative to `pagesDirPath`. */
pagesPath: string;
/** @see {@link PagesPostMetadata.permalink} */
permalink: string;
/** Locale name. */
locale: string;
}) => string | undefined;
export type Metadata = JSXPageMetadata | MDXPageMetadata;
export type LoadedContent = Metadata[];