mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-17 10:12:25 +02:00
fix(content-docs): make category index text translatable (#7233)
This commit is contained in:
parent
996901b53b
commit
10a5ebecec
6 changed files with 121 additions and 104 deletions
|
@ -6,9 +6,79 @@
|
|||
*/
|
||||
|
||||
import {toGlobalDataVersion} from '../globalData';
|
||||
import {createSidebarsUtils} from '../sidebars/utils';
|
||||
import {getCategoryGeneratedIndexMetadataList} from '../categoryGeneratedIndex';
|
||||
import type {Sidebars} from '../sidebars/types';
|
||||
|
||||
describe('toGlobalDataVersion', () => {
|
||||
it('generates the right docs, sidebars, and metadata', () => {
|
||||
const docs = [
|
||||
{
|
||||
unversionedId: 'main',
|
||||
permalink: '/current/main',
|
||||
sidebar: 'tutorial',
|
||||
frontMatter: {},
|
||||
},
|
||||
{
|
||||
unversionedId: 'doc',
|
||||
permalink: '/current/doc',
|
||||
sidebar: 'tutorial',
|
||||
frontMatter: {},
|
||||
},
|
||||
];
|
||||
const sidebars: Sidebars = {
|
||||
tutorial: [
|
||||
{
|
||||
type: 'doc',
|
||||
id: 'main',
|
||||
},
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Generated',
|
||||
link: {
|
||||
type: 'generated-index',
|
||||
permalink: '/current/generated',
|
||||
slug: '/current/generated',
|
||||
},
|
||||
items: [
|
||||
{
|
||||
type: 'doc',
|
||||
id: 'doc',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
links: [
|
||||
{
|
||||
type: 'link',
|
||||
href: 'foo',
|
||||
label: 'Foo',
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
href: 'bar',
|
||||
label: 'Bar',
|
||||
},
|
||||
],
|
||||
another: [
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Generated',
|
||||
link: {
|
||||
type: 'generated-index',
|
||||
permalink: '/current/generated-2',
|
||||
slug: '/current/generated-2',
|
||||
},
|
||||
items: [
|
||||
{
|
||||
type: 'doc',
|
||||
id: 'doc',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const sidebarsUtils = createSidebarsUtils(sidebars);
|
||||
expect(
|
||||
toGlobalDataVersion({
|
||||
versionName: 'current',
|
||||
|
@ -16,18 +86,7 @@ describe('toGlobalDataVersion', () => {
|
|||
isLast: true,
|
||||
path: '/current',
|
||||
mainDocId: 'main',
|
||||
docs: [
|
||||
{
|
||||
unversionedId: 'main',
|
||||
permalink: '/current/main',
|
||||
sidebar: 'tutorial',
|
||||
},
|
||||
{
|
||||
unversionedId: 'doc',
|
||||
permalink: '/current/doc',
|
||||
sidebar: 'tutorial',
|
||||
},
|
||||
],
|
||||
docs,
|
||||
drafts: [
|
||||
{
|
||||
unversionedId: 'some-draft-id',
|
||||
|
@ -35,64 +94,12 @@ describe('toGlobalDataVersion', () => {
|
|||
sidebar: undefined,
|
||||
},
|
||||
],
|
||||
sidebars: {
|
||||
another: [
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Generated',
|
||||
link: {
|
||||
type: 'generated-index',
|
||||
permalink: '/current/generated',
|
||||
},
|
||||
items: [
|
||||
{
|
||||
type: 'doc',
|
||||
id: 'doc',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
tutorial: [
|
||||
{
|
||||
type: 'doc',
|
||||
id: 'main',
|
||||
},
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Generated',
|
||||
link: {
|
||||
type: 'generated-index',
|
||||
permalink: '/current/generated',
|
||||
},
|
||||
items: [
|
||||
{
|
||||
type: 'doc',
|
||||
id: 'doc',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
links: [
|
||||
{
|
||||
type: 'link',
|
||||
href: 'foo',
|
||||
label: 'Foo',
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
href: 'bar',
|
||||
label: 'Bar',
|
||||
},
|
||||
],
|
||||
},
|
||||
categoryGeneratedIndices: [
|
||||
{
|
||||
title: 'Generated',
|
||||
slug: '/current/generated',
|
||||
permalink: '/current/generated',
|
||||
sidebar: 'tutorial',
|
||||
},
|
||||
],
|
||||
sidebars,
|
||||
categoryGeneratedIndices: getCategoryGeneratedIndexMetadataList({
|
||||
docs,
|
||||
sidebarsUtils,
|
||||
}),
|
||||
sidebarsUtils,
|
||||
banner: 'unreleased',
|
||||
badge: true,
|
||||
className: 'current-cls',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue