fix(content-docs): allow translating doc labels in sidebars.js (#7634)

This commit is contained in:
Joshua Chen 2022-06-16 22:11:21 +08:00 committed by GitHub
parent 5fe33bef06
commit 20e8e90762
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 159 additions and 6 deletions

View file

@ -1,5 +1,52 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`normalization adds a translatable marker for labels defined in sidebars.js 1`] = `
{
"sidebar": [
{
"id": "google",
"label": "Google",
"translatable": true,
"type": "doc",
},
{
"items": [
{
"id": "doc1",
"type": "doc",
},
{
"id": "doc2",
"type": "doc",
},
],
"label": "Category 1",
"type": "category",
},
{
"items": [
{
"id": "doc3",
"type": "doc",
},
{
"id": "doc4",
"type": "doc",
},
{
"id": "msft",
"label": "Microsoft",
"translatable": true,
"type": "ref",
},
],
"label": "Category 2",
"type": "category",
},
],
}
`;
exports[`normalization normalizes shorthands 1`] = `
{
"sidebar": [

View file

@ -91,4 +91,30 @@ describe('normalization', () => {
`"Invalid sidebar items collection \`"item"\` in sidebar sidebar: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a \`type\` property). See https://docusaurus.io/docs/sidebar/items for all valid syntaxes."`,
);
});
it('adds a translatable marker for labels defined in sidebars.js', () => {
expect(
normalizeSidebars({
sidebar: [
{
type: 'doc',
id: 'google',
label: 'Google',
},
{
'Category 1': ['doc1', 'doc2'],
'Category 2': [
'doc3',
'doc4',
{
type: 'ref',
id: 'msft',
label: 'Microsoft',
},
],
},
],
}),
).toMatchSnapshot();
});
});