Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: backport retro compatible commits for the Docusaurus v2.1 release #8033

Merged
merged 19 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d521c74
fix: collapse siblings when first category is selected (#7786)
whiteand Jul 15, 2022
d0bc176
fix(theme-classic): code block line number display with line wrapping…
yzhe819 Aug 7, 2022
0f0570f
chore(theme-translations): complete vi translations (#7928)
datlechin Aug 9, 2022
fb710b6
docs: remove mention of beta (#7905)
Josh-Cena Aug 9, 2022
dbc2c09
feat(theme-classic): use lang attribute in navbar locale dropdown ite…
slorber Aug 12, 2022
7c83ced
refactor(theme-classic): make tag text visually certered (#7876)
Kosai106 Aug 9, 2022
745d0ea
feat(core): add new Webpack file-loader extensions: avif, mov, mkv, m…
slorber Aug 11, 2022
7d25a02
refactor(theme-classic): split AnnouncementBar, increase z-index, use…
slorber Aug 12, 2022
8447a29
feat(plugin-docs): docs sidebar item link: support "autoAddBaseUrl" a…
slorber Aug 12, 2022
6f1d066
feat(theme): adds Ukrainian default theme translations (#7953)
b-ovsepian Aug 16, 2022
c458f28
fix(sitemap): filter all routes with robots meta containing noindex (…
slorber Aug 17, 2022
5edb652
feat(docs): allow to configure noIndex per doc version (#7963)
slorber Aug 17, 2022
0a2ab30
fix(core): allow overriding ssr/dev template meta tags (#7952)
slorber Aug 19, 2022
62c2d1b
fix(core): CLI command write-translations should extract translations…
slorber Aug 24, 2022
41aa801
fix(theme): add aria-label to skip to content link region (#7982)
YoniChechik Aug 24, 2022
27e3b98
fix(core): preload should support encoded page links (#7977)
adventure-yunfei Aug 25, 2022
6b65355
feat(theme): ability to use <DocCardList> without items prop, on any …
slorber Aug 26, 2022
dc587bb
fix(preset-classic): broken link in "unrecognized keys" error message…
mdubus Aug 31, 2022
b9e8721
fix(create-docusaurus): tutorial and init template improvements (#8032)
slorber Sep 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/create-docusaurus/templates/facebook/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ module.exports = {
// But you can create a sidebar manually
/*
tutorialSidebar: [
'intro',
'hello',
{
type: 'category',
label: 'Tutorial',
items: ['hello'],
items: ['tutorial-basics/create-a-document'],
},
],
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Anything **unclear** or **buggy** in this tutorial? [Please report it!](https://

## What's next?

- Read the [official documentation](https://docusaurus.io/).
- Read the [official documentation](https://docusaurus.io/)
- Modify your site configuration with [`docusaurus.config.js`](https://docusaurus.io/docs/api/docusaurus-config)
- Add navbar and footer items with [`themeConfig`](https://docusaurus.io/docs/api/themes/configuration)
- Add a custom [Design and Layout](https://docusaurus.io/docs/styling-layout)
- Add a [search bar](https://docusaurus.io/docs/search)
- Find inspirations in the [Docusaurus showcase](https://docusaurus.io/showcase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ It is also possible to create your sidebar explicitly in `sidebars.js`:
```js title="sidebars.js"
module.exports = {
tutorialSidebar: [
'intro',
// highlight-next-line
'hello',
{
type: 'category',
label: 'Tutorial',
// highlight-next-line
items: ['hello'],
items: ['tutorial-basics/create-a-document'],
},
],
};
Expand Down
4 changes: 3 additions & 1 deletion packages/create-docusaurus/templates/shared/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ const sidebars = {
// But you can create a sidebar manually
/*
tutorialSidebar: [
'intro',
'hello',
{
type: 'category',
label: 'Tutorial',
items: ['hello'],
items: ['tutorial-basics/create-a-document'],
},
],
*/
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"webpack": "^5.73.0"
},
"devDependencies": {
"@docusaurus/types": "2.0.0-beta.21",
"escape-string-regexp": "^4.0.0"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"webpack": "^5.73.0"
},
"devDependencies": {
"@docusaurus/types": "2.0.0-beta.21",
"@types/js-yaml": "^4.0.5",
"@types/picomatch": "^2.3.0",
"commander": "^5.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ exports[`simple website content: data 1`] = `
"label": "Next",
"banner": null,
"badge": false,
"noIndex": false,
"className": "docs-version-current",
"isLast": true,
"docsSidebars": {
Expand Down Expand Up @@ -2608,6 +2609,7 @@ exports[`versioned website (community) content: data 1`] = `
"label": "1.0.0",
"banner": null,
"badge": true,
"noIndex": false,
"className": "docs-version-1.0.0",
"isLast": true,
"docsSidebars": {
Expand Down Expand Up @@ -2635,6 +2637,7 @@ exports[`versioned website (community) content: data 1`] = `
"label": "Next",
"banner": "unreleased",
"badge": true,
"noIndex": false,
"className": "docs-version-current",
"isLast": false,
"docsSidebars": {
Expand Down Expand Up @@ -3477,6 +3480,7 @@ exports[`versioned website content: data 1`] = `
"label": "1.0.0",
"banner": "unmaintained",
"badge": true,
"noIndex": false,
"className": "docs-version-1.0.0",
"isLast": false,
"docsSidebars": {
Expand Down Expand Up @@ -3544,6 +3548,7 @@ exports[`versioned website content: data 1`] = `
"label": "1.0.1",
"banner": null,
"badge": true,
"noIndex": true,
"className": "docs-version-1.0.1",
"isLast": true,
"docsSidebars": {
Expand Down Expand Up @@ -3599,6 +3604,7 @@ exports[`versioned website content: data 1`] = `
"label": "Next",
"banner": "unreleased",
"badge": true,
"noIndex": false,
"className": "docs-version-current",
"isLast": false,
"docsSidebars": {
Expand Down Expand Up @@ -3674,6 +3680,7 @@ exports[`versioned website content: data 1`] = `
"label": "withSlugs",
"banner": "unmaintained",
"badge": true,
"noIndex": false,
"className": "docs-version-withSlugs",
"isLast": false,
"docsSidebars": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ describe('versioned website', () => {
options: {
routeBasePath,
sidebarPath,
versions: {
'1.0.1': {
noIndex: true,
},
},
},
});
const plugin = await pluginContentDocs(context, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('normalizeDocsPluginOptions', () => {
version1: {
path: 'hello',
label: 'world',
noIndex: true,
},
},
sidebarCollapsible: false,
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-docs/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const VersionOptionsSchema = Joi.object({
banner: Joi.string().equal('none', 'unreleased', 'unmaintained').optional(),
badge: Joi.boolean().optional(),
className: Joi.string().optional(),
noIndex: Joi.boolean().optional(),
});

const VersionsOptionsSchema = Joi.object()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,25 @@ declare module '@docusaurus/plugin-content-docs' {
// TODO support custom version banner?
// {type: "error", content: "html content"}
export type VersionBanner = 'unreleased' | 'unmaintained';

export type VersionOptions = {
/**
* The base path of the version, will be appended to `baseUrl` +
* `routeBasePath`.
*/
path?: string;
/** The label of the version to be used in badges, dropdowns, etc. */
label?: string;
/** The banner to show at the top of a doc of that version. */
banner?: 'none' | VersionBanner;
/** Show a badge with the version label at the top of each doc. */
badge?: boolean;
/** Prevents search engines from indexing this version */
noIndex?: boolean;
/** Add a custom class name to the <html> element of each doc. */
className?: string;
};

export type VersionsOptions = {
/**
* The version navigated to in priority and displayed by default for docs
Expand All @@ -144,23 +163,7 @@ declare module '@docusaurus/plugin-content-docs' {
/** Include the current version of your docs. */
includeCurrentVersion: boolean;
/** Independent customization of each version's properties. */
versions: {
[versionName: string]: {
/**
* The base path of the version, will be appended to `baseUrl` +
* `routeBasePath`.
*/
path?: string;
/** The label of the version to be used in badges, dropdowns, etc. */
label?: string;
/** The banner to show at the top of a doc of that version. */
banner?: 'none' | VersionBanner;
/** Show a badge with the version label at the top of each doc. */
badge?: boolean;
/** Add a custom class name to the <html> element of each doc. */
className?: string;
};
};
versions: {[versionName: string]: VersionOptions};
};
export type SidebarOptions = {
/**
Expand Down Expand Up @@ -263,6 +266,8 @@ declare module '@docusaurus/plugin-content-docs' {
banner: VersionBanner | null;
/** Show a badge with the version label at the top of each doc. */
badge: boolean;
/** Prevents search engines from indexing this version */
noIndex: boolean;
/** Add a custom class name to the <html> element of each doc. */
className: string;
/**
Expand Down Expand Up @@ -500,7 +505,7 @@ declare module '@docusaurus/plugin-content-docs' {

export type PropVersionMetadata = Pick<
VersionMetadata,
'label' | 'banner' | 'badge' | 'className' | 'isLast'
'label' | 'banner' | 'badge' | 'className' | 'isLast' | 'noIndex'
> & {
/** ID of the docs plugin this version belongs to. */
pluginId: string;
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-docs/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export function toVersionMetadataProp(
label: loadedVersion.label,
banner: loadedVersion.banner,
badge: loadedVersion.badge,
noIndex: loadedVersion.noIndex,
className: loadedVersion.className,
isLast: loadedVersion.isLast,
docsSidebars: toSidebarsProp(loadedVersion),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type SidebarItemLink = SidebarItemBase & {
type: 'link';
href: string;
label: string;
autoAddBaseUrl?: boolean;
};

export type SidebarItemAutogenerated = SidebarItemBase & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const sidebarItemHtmlSchema = sidebarItemBaseSchema.append<SidebarItemHtml>({
const sidebarItemLinkSchema = sidebarItemBaseSchema.append<SidebarItemLink>({
type: 'link',
href: URISchema.required(),
autoAddBaseUrl: Joi.boolean(),
label: Joi.string()
.required()
.messages({'any.unknown': '"label" must be a string'}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('readVersionsMetadata', () => {
path: '/docs',
banner: null,
badge: false,
noIndex: false,
className: 'docs-version-current',
};
return {simpleSiteDir, defaultOptions, defaultContext, vCurrent};
Expand Down Expand Up @@ -218,6 +219,7 @@ describe('readVersionsMetadata', () => {
path: '/docs/next',
banner: 'unreleased',
badge: true,
noIndex: false,
className: 'docs-version-current',
};

Expand All @@ -242,6 +244,7 @@ describe('readVersionsMetadata', () => {
path: '/docs',
banner: null,
badge: true,
noIndex: false,
className: 'docs-version-1.0.1',
};

Expand All @@ -266,6 +269,7 @@ describe('readVersionsMetadata', () => {
path: '/docs/1.0.0',
banner: 'unmaintained',
badge: true,
noIndex: false,
className: 'docs-version-1.0.0',
};

Expand All @@ -290,6 +294,7 @@ describe('readVersionsMetadata', () => {
path: '/docs/withSlugs',
banner: 'unmaintained',
badge: true,
noIndex: false,
className: 'docs-version-withSlugs',
};

Expand Down Expand Up @@ -657,6 +662,7 @@ describe('readVersionsMetadata', () => {
path: '/communityBasePath/next',
banner: 'unreleased',
badge: true,
noIndex: false,
className: 'docs-version-current',
};

Expand All @@ -681,6 +687,7 @@ describe('readVersionsMetadata', () => {
path: '/communityBasePath',
banner: null,
badge: true,
noIndex: false,
className: 'docs-version-1.0.0',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ export function getVersionBadge({
return options.versions[versionName]?.badge ?? defaultVersionBadge;
}

export function getVersionNoIndex({
versionName,
options,
}: VersionContext): VersionMetadata['noIndex'] {
return options.versions[versionName]?.noIndex ?? false;
}

function getVersionClassName({
versionName,
options,
Expand Down Expand Up @@ -179,6 +186,7 @@ async function createVersionMetadata(
label: getVersionLabel(context),
banner: getVersionBanner(context),
badge: getVersionBadge(context),
noIndex: getVersionNoIndex(context),
className: getVersionClassName(context),
path: routePath,
tagsPath: normalizeUrl([routePath, options.tagsBasePath]),
Expand Down
3 changes: 0 additions & 3 deletions packages/docusaurus-plugin-content-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
"tslib": "^2.4.0",
"webpack": "^5.73.0"
},
"devDependencies": {
"@docusaurus/types": "2.0.0-beta.21"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
Expand Down
3 changes: 0 additions & 3 deletions packages/docusaurus-plugin-debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
"react-json-view": "^1.21.3",
"tslib": "^2.4.0"
},
"devDependencies": {
"@docusaurus/types": "2.0.0-beta.21"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
Expand Down
3 changes: 0 additions & 3 deletions packages/docusaurus-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
"@docusaurus/utils-validation": "2.0.1",
"tslib": "^2.4.0"
},
"devDependencies": {
"@docusaurus/types": "2.0.0-beta.21"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
Expand Down
3 changes: 0 additions & 3 deletions packages/docusaurus-plugin-google-gtag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
"@docusaurus/utils-validation": "2.0.1",
"tslib": "^2.4.0"
},
"devDependencies": {
"@docusaurus/types": "2.0.0-beta.21"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-ideal-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.1",
"@docusaurus/types": "2.0.0-beta.21",
"fs-extra": "^10.1.0"
},
"peerDependencies": {
Expand Down
3 changes: 0 additions & 3 deletions packages/docusaurus-plugin-sitemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
"sitemap": "^7.1.1",
"tslib": "^2.4.0"
},
"devDependencies": {
"@docusaurus/types": "2.0.0-beta.21"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ describe('createSitemap', () => {
meta: {
// @ts-expect-error: bad lib def
toComponent: () => [
React.createElement('meta', {name: 'robots', content: 'noindex'}),
React.createElement('meta', {
name: 'robots',
content: 'NoFolloW, NoiNDeX',
}),
],
},
},
Expand Down
Loading