mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
Add sidebar_key attribute to docs front matter validation
This commit is contained in:
parent
64afe155ca
commit
60760d601e
|
|
@ -186,10 +186,24 @@ describe('validateDocFrontMatter slug', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('validateDocFrontMatter sidebar_key', () => {
|
||||
testField({
|
||||
prefix: 'sidebar_key',
|
||||
validFrontMatters: [
|
||||
{sidebar_key: undefined},
|
||||
{sidebar_key: 'Awesome docs'},
|
||||
],
|
||||
invalidFrontMatters: [[{sidebar_key: ''}, 'is not allowed to be empty']],
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateDocFrontMatter sidebar_label', () => {
|
||||
testField({
|
||||
prefix: 'sidebar_label',
|
||||
validFrontMatters: [{sidebar_label: 'Awesome docs'}],
|
||||
validFrontMatters: [
|
||||
{sidebar_label: undefined},
|
||||
{sidebar_label: 'Awesome docs'},
|
||||
],
|
||||
invalidFrontMatters: [[{sidebar_label: ''}, 'is not allowed to be empty']],
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ export const DocFrontMatterSchema = Joi.object<DocFrontMatter>({
|
|||
// See https://github.com/facebook/docusaurus/issues/4591#issuecomment-822372398
|
||||
description: Joi.string().allow(''),
|
||||
slug: Joi.string(),
|
||||
sidebar_key: Joi.string(),
|
||||
sidebar_label: Joi.string(),
|
||||
sidebar_position: Joi.number(),
|
||||
sidebar_class_name: Joi.string(),
|
||||
|
|
|
|||
|
|
@ -339,7 +339,15 @@ declare module '@docusaurus/plugin-content-docs' {
|
|||
* @see {@link DocMetadata.slug}
|
||||
*/
|
||||
slug?: string;
|
||||
/** Customizes the sidebar label for this doc. Will default to its title. */
|
||||
/**
|
||||
* Customizes the sidebar key for this doc,
|
||||
* to uniquely identify it in translations.
|
||||
*/
|
||||
sidebar_key?: string;
|
||||
/**
|
||||
* Customizes the sidebar label for this doc.
|
||||
* Will default to its title.
|
||||
*/
|
||||
sidebar_label?: string;
|
||||
/**
|
||||
* Controls the position of a doc inside the generated sidebar slice when
|
||||
|
|
|
|||
Loading…
Reference in New Issue