mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-31 01:47:17 +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({
|
||||
validate: normalizePluginOptions,
|
||||
options: {
|
||||
// todo broken because we use aliasedPaths
|
||||
path: 'src/showcase',
|
||||
},
|
||||
}),
|
||||
|
|
|
@ -83,25 +83,25 @@ describe('normalizeShowcasePluginOptions', () => {
|
|||
userOptions,
|
||||
),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`""tags" must be one of [string, array]"`,
|
||||
`""tags" must be one of [string, object]"`,
|
||||
);
|
||||
});
|
||||
|
||||
it('accepts correctly defined tags object options', () => {
|
||||
const userOptions = {
|
||||
tags: [
|
||||
{
|
||||
foo: {
|
||||
label: 'foo',
|
||||
description: {
|
||||
message: 'bar',
|
||||
id: 'baz',
|
||||
},
|
||||
color: 'red',
|
||||
tags: {
|
||||
favorite: {
|
||||
label: 'Favorite',
|
||||
description: {
|
||||
message:
|
||||
'Our favorite Docusaurus sites that you must absolutely check out!',
|
||||
id: 'showcase.tag.favorite.description',
|
||||
},
|
||||
color: '#e9669e',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
// todo fix ts error
|
||||
expect(testValidate(userOptions)).toEqual({
|
||||
...defaultOptions,
|
||||
...userOptions,
|
||||
|
@ -110,22 +110,25 @@ describe('normalizeShowcasePluginOptions', () => {
|
|||
|
||||
it('reject bedly defined tags object options', () => {
|
||||
const userOptions = {
|
||||
tags: [
|
||||
{
|
||||
label: 'foo',
|
||||
tags: {
|
||||
favorite: {
|
||||
label: 32,
|
||||
description: {
|
||||
message: 'bar',
|
||||
id: 'baz',
|
||||
message:
|
||||
'Our favorite Docusaurus sites that you must absolutely check out!',
|
||||
id: 'showcase.tag.favorite.description',
|
||||
},
|
||||
color: 42,
|
||||
color: '#e9669e',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
expect(() =>
|
||||
testValidate(
|
||||
// @ts-expect-error: bad attributes
|
||||
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(
|
||||
// todo should we use aliasedPath ?
|
||||
// because it breaks tests showcase/index.test.ts#L27-L28
|
||||
aliasedSitePathToRelativePath(filePath),
|
||||
'utf-8',
|
||||
);
|
||||
|
@ -95,6 +97,7 @@ export default function pluginContentShowcase(
|
|||
if (!(await fs.pathExists(contentPaths.contentPath))) {
|
||||
return null;
|
||||
}
|
||||
console.log('contentPaths:', contentPaths);
|
||||
|
||||
const {include} = options;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue