mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 11:22:30 +02:00
chore: add cSpell for spell checking (#6456)
* chore: Add cSpell for spell checking * chore: exclude map files and remove dups * chore: exclude more binary files * chore: remove MD headings * Update .cspell.json * fix a few spellings * fix more * fix Signed-off-by: Joshua Chen <sidachen2003@gmail.com> * fix a few * oops Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
a41a5c328c
commit
521eb119a7
64 changed files with 852 additions and 142 deletions
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
custom_edit_url: https://github.com/customUrl/docs/lorem.md
|
||||
unrelated_frontmatter: won't be part of metadata
|
||||
unrelated_front_matter: won't be part of metadata
|
||||
---
|
||||
|
||||
Lorem ipsum.
|
||||
|
|
|
@ -529,7 +529,7 @@ Object {
|
|||
\\"version\\": \\"current\\",
|
||||
\\"frontMatter\\": {
|
||||
\\"custom_edit_url\\": \\"https://github.com/customUrl/docs/lorem.md\\",
|
||||
\\"unrelated_frontmatter\\": \\"won't be part of metadata\\"
|
||||
\\"unrelated_front_matter\\": \\"won't be part of metadata\\"
|
||||
}
|
||||
}",
|
||||
"site-docs-root-absolute-slug-md-db5.json": "{
|
||||
|
|
|
@ -44,7 +44,7 @@ function testField(params: {
|
|||
// eslint-disable-next-line jest/no-jasmine-globals
|
||||
fail(
|
||||
new Error(
|
||||
`Doc frontmatter is expected to be rejected, but was accepted successfully:\n ${JSON.stringify(
|
||||
`Doc front matter is expected to be rejected, but was accepted successfully:\n ${JSON.stringify(
|
||||
frontMatter,
|
||||
null,
|
||||
2,
|
||||
|
|
|
@ -37,15 +37,15 @@ const fixtureDir = path.join(__dirname, '__fixtures__');
|
|||
|
||||
const createFakeDocFile = ({
|
||||
source,
|
||||
frontmatter = {},
|
||||
frontMatter = {},
|
||||
markdown = 'some markdown content',
|
||||
}: {
|
||||
source: string;
|
||||
frontmatter?: Record<string, string>;
|
||||
frontMatter?: Record<string, string>;
|
||||
markdown?: string;
|
||||
}): DocFile => {
|
||||
const content = `---
|
||||
${Object.entries(frontmatter)
|
||||
${Object.entries(frontMatter)
|
||||
.map(([key, value]) => `${key}: ${value}`)
|
||||
.join('\n')}
|
||||
---
|
||||
|
@ -313,7 +313,7 @@ describe('simple site', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('docs with custom editUrl & unrelated frontmatter', async () => {
|
||||
test('docs with custom editUrl & unrelated frontMatter', async () => {
|
||||
const {defaultTestUtils} = await loadSite();
|
||||
|
||||
await defaultTestUtils.testMeta('lorem.md', {
|
||||
|
@ -328,7 +328,7 @@ describe('simple site', () => {
|
|||
description: 'Lorem ipsum.',
|
||||
frontMatter: {
|
||||
custom_edit_url: 'https://github.com/customUrl/docs/lorem.md',
|
||||
unrelated_frontmatter: "won't be part of metadata",
|
||||
unrelated_front_matter: "won't be part of metadata",
|
||||
},
|
||||
tags: [],
|
||||
});
|
||||
|
@ -422,7 +422,7 @@ describe('simple site', () => {
|
|||
description: 'Lorem ipsum.',
|
||||
frontMatter: {
|
||||
custom_edit_url: 'https://github.com/customUrl/docs/lorem.md',
|
||||
unrelated_frontmatter: "won't be part of metadata",
|
||||
unrelated_front_matter: "won't be part of metadata",
|
||||
},
|
||||
lastUpdatedAt: 1539502055,
|
||||
formattedLastUpdatedAt: '10/14/2018',
|
||||
|
@ -475,7 +475,7 @@ describe('simple site', () => {
|
|||
defaultTestUtils.processDocFile(
|
||||
createFakeDocFile({
|
||||
source: 'some/fake/path',
|
||||
frontmatter: {
|
||||
frontMatter: {
|
||||
id: 'Hello/world',
|
||||
},
|
||||
}),
|
||||
|
@ -499,7 +499,7 @@ describe('simple site', () => {
|
|||
docs.push(
|
||||
createFakeDocFile({
|
||||
source: 'hehe',
|
||||
frontmatter: {pagination_prev: 'nonexistent'},
|
||||
frontMatter: {pagination_prev: 'nonexistent'},
|
||||
}),
|
||||
);
|
||||
await expect(
|
||||
|
|
|
@ -70,13 +70,13 @@ describe('getSlug', () => {
|
|||
).toEqual('/dir/subdir/');
|
||||
});
|
||||
|
||||
test('should ignore conventional doc index when explicit slug frontmatter is provided', () => {
|
||||
test('should ignore conventional doc index when explicit slug front matter is provided', () => {
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'doc',
|
||||
source: '@site/docs/dir/subdir/index.md',
|
||||
sourceDirName: '/dir/subdir',
|
||||
frontmatterSlug: '/my/frontMatterSlug',
|
||||
frontMatterSlug: '/my/frontMatterSlug',
|
||||
}),
|
||||
).toEqual('/my/frontMatterSlug');
|
||||
});
|
||||
|
@ -120,13 +120,13 @@ describe('getSlug', () => {
|
|||
).toEqual('/doc');
|
||||
});
|
||||
|
||||
test('should resolve absolute slug frontmatter', () => {
|
||||
test('should resolve absolute slug front matter', () => {
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
source: '@site/docs/doc.md',
|
||||
sourceDirName: '.',
|
||||
frontmatterSlug: '/abc/def',
|
||||
frontMatterSlug: '/abc/def',
|
||||
}),
|
||||
).toEqual('/abc/def');
|
||||
expect(
|
||||
|
@ -134,7 +134,7 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/any/doc.md',
|
||||
sourceDirName: './any',
|
||||
frontmatterSlug: '/abc/def',
|
||||
frontMatterSlug: '/abc/def',
|
||||
}),
|
||||
).toEqual('/abc/def');
|
||||
expect(
|
||||
|
@ -142,18 +142,18 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/any/any/doc.md',
|
||||
sourceDirName: './any/any',
|
||||
frontmatterSlug: '/abc/def',
|
||||
frontMatterSlug: '/abc/def',
|
||||
}),
|
||||
).toEqual('/abc/def');
|
||||
});
|
||||
|
||||
test('should resolve relative slug frontmatter', () => {
|
||||
test('should resolve relative slug front matter', () => {
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
source: '@site/docs/doc.md',
|
||||
sourceDirName: '.',
|
||||
frontmatterSlug: 'abc/def',
|
||||
frontMatterSlug: 'abc/def',
|
||||
}),
|
||||
).toEqual('/abc/def');
|
||||
expect(
|
||||
|
@ -161,7 +161,7 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/dir/doc.md',
|
||||
sourceDirName: '/dir',
|
||||
frontmatterSlug: 'abc/def',
|
||||
frontMatterSlug: 'abc/def',
|
||||
}),
|
||||
).toEqual('/dir/abc/def');
|
||||
expect(
|
||||
|
@ -169,7 +169,7 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/unslashedDir/doc.md',
|
||||
sourceDirName: 'unslashedDir',
|
||||
frontmatterSlug: 'abc/def',
|
||||
frontMatterSlug: 'abc/def',
|
||||
}),
|
||||
).toEqual('/unslashedDir/abc/def');
|
||||
expect(
|
||||
|
@ -177,7 +177,7 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/dir/subdir/doc.md',
|
||||
sourceDirName: 'dir/subdir',
|
||||
frontmatterSlug: 'abc/def',
|
||||
frontMatterSlug: 'abc/def',
|
||||
}),
|
||||
).toEqual('/dir/subdir/abc/def');
|
||||
expect(
|
||||
|
@ -185,7 +185,7 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/dir/doc.md',
|
||||
sourceDirName: '/dir',
|
||||
frontmatterSlug: './abc/def',
|
||||
frontMatterSlug: './abc/def',
|
||||
}),
|
||||
).toEqual('/dir/abc/def');
|
||||
expect(
|
||||
|
@ -193,7 +193,7 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/dir/doc.md',
|
||||
sourceDirName: '/dir',
|
||||
frontmatterSlug: './abc/../def',
|
||||
frontMatterSlug: './abc/../def',
|
||||
}),
|
||||
).toEqual('/dir/def');
|
||||
expect(
|
||||
|
@ -201,7 +201,7 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/dir/subdir/doc.md',
|
||||
sourceDirName: '/dir/subdir',
|
||||
frontmatterSlug: '../abc/def',
|
||||
frontMatterSlug: '../abc/def',
|
||||
}),
|
||||
).toEqual('/dir/abc/def');
|
||||
expect(
|
||||
|
@ -209,7 +209,7 @@ describe('getSlug', () => {
|
|||
baseID: 'any',
|
||||
source: '@site/docs/dir/subdirdoc.md',
|
||||
sourceDirName: '/dir/subdir',
|
||||
frontmatterSlug: '../../../../../abc/../def',
|
||||
frontMatterSlug: '../../../../../abc/../def',
|
||||
}),
|
||||
).toEqual('/def');
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
JoiFrontMatter as Joi, // Custom instance for frontmatter
|
||||
JoiFrontMatter as Joi, // Custom instance for front matter
|
||||
URISchema,
|
||||
FrontMatterTagsSchema,
|
||||
FrontMatterTOCHeadingLevels,
|
||||
|
|
|
@ -138,7 +138,7 @@ function doProcessDocMetadata({
|
|||
custom_edit_url: customEditURL,
|
||||
|
||||
// Strip number prefixes by default (01-MyFolder/01-MyDoc.md => MyFolder/MyDoc) by default,
|
||||
// but allow to disable this behavior with frontmatter
|
||||
// but allow to disable this behavior with front matter
|
||||
parse_number_prefixes: parseNumberPrefixes = true,
|
||||
} = frontMatter;
|
||||
|
||||
|
@ -162,7 +162,7 @@ function doProcessDocMetadata({
|
|||
throw new Error(`Document id "${baseID}" cannot include slash.`);
|
||||
}
|
||||
|
||||
// For autogenerated sidebars, sidebar position can come from filename number prefix or frontmatter
|
||||
// For autogenerated sidebars, sidebar position can come from filename number prefix or front matter
|
||||
const sidebarPosition: number | undefined =
|
||||
frontMatter.sidebar_position ?? numberPrefix;
|
||||
|
||||
|
@ -175,7 +175,7 @@ function doProcessDocMetadata({
|
|||
: `version-${versionMetadata.versionName}`;
|
||||
|
||||
// TODO legacy retrocompatibility
|
||||
// I think it's bad to affect the frontmatter id with the dirname?
|
||||
// I think it's bad to affect the front matter id with the dirname?
|
||||
function computeDirNameIdPrefix() {
|
||||
if (sourceDirName === '.') {
|
||||
return undefined;
|
||||
|
@ -198,7 +198,7 @@ function doProcessDocMetadata({
|
|||
baseID,
|
||||
source,
|
||||
sourceDirName,
|
||||
frontmatterSlug: frontMatter.slug,
|
||||
frontMatterSlug: frontMatter.slug,
|
||||
stripDirNumberPrefixes: parseNumberPrefixes,
|
||||
numberPrefixParser: options.numberPrefixParser,
|
||||
});
|
||||
|
|
|
@ -606,7 +606,7 @@ describe('toDocNavigationLink', () => {
|
|||
return data as DocMetadataBase;
|
||||
}
|
||||
|
||||
test('with no frontmatter', () => {
|
||||
test('with no front matter', () => {
|
||||
expect(
|
||||
toDocNavigationLink(
|
||||
testDoc({
|
||||
|
@ -621,7 +621,7 @@ describe('toDocNavigationLink', () => {
|
|||
} as DocNavLink);
|
||||
});
|
||||
|
||||
test('with pagination_label frontmatter', () => {
|
||||
test('with pagination_label front matter', () => {
|
||||
expect(
|
||||
toDocNavigationLink(
|
||||
testDoc({
|
||||
|
@ -638,7 +638,7 @@ describe('toDocNavigationLink', () => {
|
|||
} as DocNavLink);
|
||||
});
|
||||
|
||||
test('with sidebar_label frontmatter', () => {
|
||||
test('with sidebar_label front matter', () => {
|
||||
expect(
|
||||
toDocNavigationLink(
|
||||
testDoc({
|
||||
|
@ -655,7 +655,7 @@ describe('toDocNavigationLink', () => {
|
|||
} as DocNavLink);
|
||||
});
|
||||
|
||||
test('with pagination_label + sidebar_label frontmatter', () => {
|
||||
test('with pagination_label + sidebar_label front matter', () => {
|
||||
expect(
|
||||
toDocNavigationLink(
|
||||
testDoc({
|
||||
|
|
|
@ -21,14 +21,14 @@ import type {NumberPrefixParser} from '@docusaurus/plugin-content-docs';
|
|||
|
||||
export default function getSlug({
|
||||
baseID,
|
||||
frontmatterSlug,
|
||||
frontMatterSlug,
|
||||
source,
|
||||
sourceDirName,
|
||||
stripDirNumberPrefixes = true,
|
||||
numberPrefixParser = DefaultNumberPrefixParser,
|
||||
}: {
|
||||
baseID: string;
|
||||
frontmatterSlug?: string;
|
||||
frontMatterSlug?: string;
|
||||
source: DocMetadataBase['slug'];
|
||||
sourceDirName: DocMetadataBase['sourceDirName'];
|
||||
stripDirNumberPrefixes?: boolean;
|
||||
|
@ -46,14 +46,14 @@ export default function getSlug({
|
|||
}
|
||||
|
||||
function computeSlug(): string {
|
||||
if (frontmatterSlug?.startsWith('/')) {
|
||||
return frontmatterSlug;
|
||||
if (frontMatterSlug?.startsWith('/')) {
|
||||
return frontMatterSlug;
|
||||
} else {
|
||||
const dirNameSlug = getDirNameSlug();
|
||||
if (!frontmatterSlug && isConventionalDocIndex({source, sourceDirName})) {
|
||||
if (!frontMatterSlug && isConventionalDocIndex({source, sourceDirName})) {
|
||||
return dirNameSlug;
|
||||
}
|
||||
const baseSlug = frontmatterSlug || baseID;
|
||||
const baseSlug = frontMatterSlug || baseID;
|
||||
return resolvePathname(baseSlug, getDirNameSlug());
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ export default function getSlug({
|
|||
throw new Error(
|
||||
`We couldn't compute a valid slug for document with id "${baseID}" in "${sourceDirName}" directory.
|
||||
The slug we computed looks invalid: ${slug}.
|
||||
Maybe your slug frontmatter is incorrect or you use weird chars in the file path?
|
||||
By using the slug frontmatter, you should be able to fix this error, by using the slug of your choice:
|
||||
Maybe your slug front matter is incorrect or you use weird chars in the file path?
|
||||
By using the slug front matter, you should be able to fix this error, by using the slug of your choice:
|
||||
|
||||
Example =>
|
||||
---
|
||||
|
|
|
@ -57,7 +57,7 @@ function getNormalizedSidebarName({
|
|||
|
||||
/*
|
||||
// Do we need to translate doc metadata?
|
||||
// It seems translating frontmatter labels is good enough
|
||||
// It seems translating front matter labels is good enough
|
||||
function getDocTranslations(doc: DocMetadata): TranslationFileContent {
|
||||
return {
|
||||
[`${doc.unversionedId}.title`]: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue