mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 10:22:30 +02:00
wip
This commit is contained in:
parent
c3f32ab781
commit
8ab6ddac54
5 changed files with 38 additions and 19 deletions
|
@ -0,0 +1,12 @@
|
||||||
|
opensource:
|
||||||
|
label: "Open-Source"
|
||||||
|
description:
|
||||||
|
message: "Open-Source Docusaurus sites can be useful for inspiration!"
|
||||||
|
id: "showcase.tag.opensource.description"
|
||||||
|
color: "#39ca30"
|
||||||
|
meta:
|
||||||
|
label: "Meta"
|
||||||
|
description:
|
||||||
|
message: "Docusaurus sites of Meta (formerly Facebook) projects"
|
||||||
|
id: "showcase.tag.meta.description"
|
||||||
|
color: "#4267b2"
|
|
@ -24,6 +24,7 @@ describe('docusaurus-plugin-content-showcase', () => {
|
||||||
validateOptions({
|
validateOptions({
|
||||||
validate: normalizePluginOptions,
|
validate: normalizePluginOptions,
|
||||||
options: {
|
options: {
|
||||||
|
// todo broken because we use aliasedPaths
|
||||||
path: 'src/showcase',
|
path: 'src/showcase',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -83,25 +83,25 @@ describe('normalizeShowcasePluginOptions', () => {
|
||||||
userOptions,
|
userOptions,
|
||||||
),
|
),
|
||||||
).toThrowErrorMatchingInlineSnapshot(
|
).toThrowErrorMatchingInlineSnapshot(
|
||||||
`""tags" must be one of [string, array]"`,
|
`""tags" must be one of [string, object]"`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts correctly defined tags object options', () => {
|
it('accepts correctly defined tags object options', () => {
|
||||||
const userOptions = {
|
const userOptions = {
|
||||||
tags: [
|
tags: {
|
||||||
{
|
favorite: {
|
||||||
foo: {
|
label: 'Favorite',
|
||||||
label: 'foo',
|
description: {
|
||||||
description: {
|
message:
|
||||||
message: 'bar',
|
'Our favorite Docusaurus sites that you must absolutely check out!',
|
||||||
id: 'baz',
|
id: 'showcase.tag.favorite.description',
|
||||||
},
|
|
||||||
color: 'red',
|
|
||||||
},
|
},
|
||||||
|
color: '#e9669e',
|
||||||
},
|
},
|
||||||
],
|
},
|
||||||
};
|
};
|
||||||
|
// todo fix ts error
|
||||||
expect(testValidate(userOptions)).toEqual({
|
expect(testValidate(userOptions)).toEqual({
|
||||||
...defaultOptions,
|
...defaultOptions,
|
||||||
...userOptions,
|
...userOptions,
|
||||||
|
@ -110,22 +110,25 @@ describe('normalizeShowcasePluginOptions', () => {
|
||||||
|
|
||||||
it('reject bedly defined tags object options', () => {
|
it('reject bedly defined tags object options', () => {
|
||||||
const userOptions = {
|
const userOptions = {
|
||||||
tags: [
|
tags: {
|
||||||
{
|
favorite: {
|
||||||
label: 'foo',
|
label: 32,
|
||||||
description: {
|
description: {
|
||||||
message: 'bar',
|
message:
|
||||||
id: 'baz',
|
'Our favorite Docusaurus sites that you must absolutely check out!',
|
||||||
|
id: 'showcase.tag.favorite.description',
|
||||||
},
|
},
|
||||||
color: 42,
|
color: '#e9669e',
|
||||||
},
|
},
|
||||||
],
|
},
|
||||||
};
|
};
|
||||||
expect(() =>
|
expect(() =>
|
||||||
testValidate(
|
testValidate(
|
||||||
// @ts-expect-error: bad attributes
|
// @ts-expect-error: bad attributes
|
||||||
userOptions,
|
userOptions,
|
||||||
),
|
),
|
||||||
).toThrowErrorMatchingInlineSnapshot(`""tags[0].color" must be a string"`);
|
).toThrowErrorMatchingInlineSnapshot(
|
||||||
|
`""tags.favorite.label" must be a string"`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -48,6 +48,8 @@ async function getTagsList(filePath: string | TagOption[]): Promise<string[]> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawYaml = await fs.readFile(
|
const rawYaml = await fs.readFile(
|
||||||
|
// todo should we use aliasedPath ?
|
||||||
|
// because it breaks tests showcase/index.test.ts#L27-L28
|
||||||
aliasedSitePathToRelativePath(filePath),
|
aliasedSitePathToRelativePath(filePath),
|
||||||
'utf-8',
|
'utf-8',
|
||||||
);
|
);
|
||||||
|
@ -95,6 +97,7 @@ export default function pluginContentShowcase(
|
||||||
if (!(await fs.pathExists(contentPaths.contentPath))) {
|
if (!(await fs.pathExists(contentPaths.contentPath))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
console.log('contentPaths:', contentPaths);
|
||||||
|
|
||||||
const {include} = options;
|
const {include} = options;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue