fix(v2): deprecate docs homePageId in favor of frontmatter "slug: /" (#3228)

* homePageId => deprecated

* docs prettier
This commit is contained in:
Sébastien Lorber 2020-08-06 18:31:50 +02:00 committed by GitHub
parent 0079f0e8d1
commit 0a33a52301
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 109 additions and 79 deletions

View file

@ -71,6 +71,16 @@ export default function pluginContentDocs(
context: LoadContext,
options: PluginOptions,
): Plugin<LoadedContent | null, typeof PluginOptionSchema> {
// TODO remove homePageId before end of 2020
// "slug: /" is better because the home doc can be different across versions
if (options.homePageId) {
console.log(
chalk.red(
`The docs plugin option homePageId=${options.homePageId} is deprecated. To make a doc the "home", prefer frontmatter: "slug: /"`,
),
);
}
if (options.admonitions) {
options.remarkPlugins = options.remarkPlugins.concat([
[admonitions, options.admonitions],
@ -424,8 +434,10 @@ Available document ids=
const docsRoutes = await genRoutes(docs);
const mainDoc: Metadata =
docs.find((doc) => doc.unversionedId === options.homePageId) ??
docs[0];
docs.find(
(doc) =>
doc.unversionedId === options.homePageId || doc.slug === '/',
) ?? docs[0];
const toGlobalDataDoc = (doc: Metadata): GlobalDoc => ({
id: doc.unversionedId,