Skip to content

Commit

Permalink
Rename isDraft to draft
Browse files Browse the repository at this point in the history
  • Loading branch information
jodyheavener committed Apr 4, 2022
1 parent 3f79f5f commit 3baa532
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 112 deletions.

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions packages/docusaurus-plugin-content-docs/src/__tests__/docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ describe('simple site', () => {
pagination_prev: null,
},
tags: [],
isDraft: false,
draft: false,
});
await defaultTestUtils.testMeta(path.join('hello.md'), {
version: 'current',
Expand Down Expand Up @@ -269,7 +269,7 @@ describe('simple site', () => {
permalink: '/docs/tags/tag-3',
},
],
isDraft: false,
draft: false,
});
});

Expand Down Expand Up @@ -319,7 +319,7 @@ describe('simple site', () => {
permalink: '/docs/tags/tag2-custom-permalink',
},
],
isDraft: false,
draft: false,
});
});

Expand All @@ -341,7 +341,7 @@ describe('simple site', () => {
unrelated_front_matter: "won't be part of metadata",
},
tags: [],
isDraft: false,
draft: false,
});
});

Expand Down Expand Up @@ -394,7 +394,7 @@ describe('simple site', () => {
permalink: '/docs/tags/tag2-custom-permalink',
},
],
isDraft: false,
draft: false,
});

expect(editUrlFunction).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -440,7 +440,7 @@ describe('simple site', () => {
formattedLastUpdatedAt: '10/14/2018',
lastUpdatedBy: 'Author',
tags: [],
isDraft: false,
draft: false,
});
});

Expand All @@ -465,7 +465,7 @@ describe('simple site', () => {
draft: true,
},
tags: [],
isDraft: true,
draft: true,
});
});

Expand Down Expand Up @@ -649,7 +649,7 @@ describe('versioned site', () => {
permalink: '/docs/next/tags/barTag-3-permalink',
},
],
isDraft: false,
draft: false,
});
await currentVersionTestUtils.testMeta(path.join('hello.md'), {
id: 'hello',
Expand All @@ -664,7 +664,7 @@ describe('versioned site', () => {
slug: '/',
},
tags: [],
isDraft: false,
draft: false,
});
});

Expand All @@ -682,7 +682,7 @@ describe('versioned site', () => {
frontMatter: {slug: 'barSlug'},
version: '1.0.0',
tags: [],
isDraft: false,
draft: false,
});
await version100TestUtils.testMeta(path.join('hello.md'), {
id: 'version-1.0.0/hello',
Expand All @@ -699,7 +699,7 @@ describe('versioned site', () => {
source:
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
tags: [],
isDraft: false,
draft: false,
});
await version101TestUtils.testMeta(path.join('foo', 'bar.md'), {
id: 'version-1.0.1/foo/bar',
Expand All @@ -712,7 +712,7 @@ describe('versioned site', () => {
version: '1.0.1',
frontMatter: {},
tags: [],
isDraft: false,
draft: false,
});
await version101TestUtils.testMeta(path.join('hello.md'), {
id: 'version-1.0.1/hello',
Expand All @@ -727,7 +727,7 @@ describe('versioned site', () => {
slug: '/',
},
tags: [],
isDraft: false,
draft: false,
});
});

Expand Down Expand Up @@ -824,7 +824,7 @@ describe('versioned site', () => {
'@site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
editUrl: hardcodedEditUrl,
tags: [],
isDraft: false,
draft: false,
});

expect(editUrlFunction).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -869,7 +869,7 @@ describe('versioned site', () => {
editUrl:
'https://github.com/facebook/docusaurus/edit/main/website/versioned_docs/version-1.0.0/hello.md',
tags: [],
isDraft: false,
draft: false,
});
});

Expand Down Expand Up @@ -905,7 +905,7 @@ describe('versioned site', () => {
editUrl:
'https://github.com/facebook/docusaurus/edit/main/website/docs/hello.md',
tags: [],
isDraft: false,
draft: false,
});
});

Expand Down Expand Up @@ -942,7 +942,7 @@ describe('versioned site', () => {
editUrl:
'https://github.com/facebook/docusaurus/edit/main/website/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md',
tags: [],
isDraft: false,
draft: false,
});
});

Expand Down Expand Up @@ -980,7 +980,7 @@ describe('versioned site', () => {
editUrl:
'https://github.com/facebook/docusaurus/edit/main/website/i18n/fr/docusaurus-plugin-content-docs/current/hello.md',
tags: [],
isDraft: false,
draft: false,
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-content-docs/src/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function doProcessDocMetadata({
} = parseMarkdownString(content);
const frontMatter = validateDocFrontMatter(unsafeFrontMatter);

const isDraft =
const draft =
(frontMatter.draft && process.env.NODE_ENV === 'production') || false;

const {
Expand Down Expand Up @@ -263,7 +263,7 @@ function doProcessDocMetadata({
: undefined,
sidebarPosition,
frontMatter,
isDraft,
draft,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ declare module '@docusaurus/plugin-content-docs' {
/** Front matter, as-is. */
frontMatter: DocFrontMatter & {[key: string]: unknown};
/** Is the doc going to be excluded from production builds? */
isDraft: boolean;
draft: boolean;
};

export type DocMetadata = DocMetadataBase &
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function createDocRoutes({
}): Promise<RouteConfig[]> {
return Promise.all(
docs
.filter((metadataItem) => !metadataItem.isDraft)
.filter((metadataItem) => !metadataItem.draft)
.map(async (metadataItem) => {
await actions.createData(
// Note that this created data path must be in sync with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ describe('DefaultSidebarItemsGenerator', () => {
frontMatter: {
draft: true,
},
isDraft: true,
draft: true,
},
{
id: 'doc2',
Expand All @@ -536,7 +536,7 @@ describe('DefaultSidebarItemsGenerator', () => {
frontMatter: {
draft: false,
},
isDraft: false,
draft: false,
},
],
options: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ describe('processSidebars', () => {
docs: [
{
id: 'doc1',
isDraft: true,
draft: true,
},
{
id: 'doc2',
isDraft: false,
draft: false,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const DefaultSidebarItemsGenerator: SidebarItemsGenerator = async ({
item: {dirName: autogenDir},
categoriesMetadata,
}) => {
const visibleDocs = allDocs.filter((doc) => !doc.isDraft);
const visibleDocs = allDocs.filter((doc) => !doc.draft);
const docsById = createDocsByIdIndex(visibleDocs);
const findDoc = (docId: string): SidebarItemsGeneratorDoc | undefined =>
docsById[docId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function toSidebarItemsGeneratorDoc(
'source',
'sourceDirName',
'sidebarPosition',
'isDraft',
'draft',
]);
}

Expand Down Expand Up @@ -96,10 +96,7 @@ async function processSidebar(
if (item.type === 'autogenerated') {
return processAutoGeneratedItem(item);
}
if (
item.type === 'doc' &&
docs.find((doc) => doc.id === item.id)?.isDraft
) {
if (item.type === 'doc' && docs.find((doc) => doc.id === item.id)?.draft) {
return [];
}
return [item];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export type SidebarItemsGeneratorDoc = Pick<
| 'source'
| 'sourceDirName'
| 'sidebarPosition'
| 'isDraft'
| 'draft'
>;
export type SidebarItemsGeneratorVersion = Pick<
VersionMetadata,
Expand Down

0 comments on commit 3baa532

Please sign in to comment.