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

refactor(v2): various fixes #3587

Merged
merged 2 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('isSamePath', () => {
});

test('should be true for compared path with trailing slash', () => {
expect(isSamePath('/docs', '/docs')).toBeTruthy();
expect(isSamePath('/docs', '/docs/')).toBeTruthy();
});

test('should be false for compared path with double trailing slash', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function DocsVersionDropdownNavbarItem({

// We don't want to render a version dropdown with 0 or 1 item
// If we build the site with a single docs version (onlyIncludeVersions: ['1.0.0'])
// We'd rather render a buttonb instead of a dropdown
// We'd rather render a button instead of a dropdown
if (items.length <= 1) {
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus/src/client/templates/ssr.html.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module.exports = `
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Docusaurus v<%= it.version %>">
<%if (it.noIndex) { %>
<meta name="robots" content="noindex" />
<% if (it.noIndex) { %>
<meta name="robots" content="noindex, nofollow" />
<% } %>
<%~ it.headTags %>
<% it.metaAttributes.forEach((metaAttribute) => { %>
Expand Down
2 changes: 1 addition & 1 deletion website-1.x/data/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ const users = [
users.forEach((user) => {
if (!user.image || !user.image.startsWith('/img/users/')) {
throw new Error(
`Bad user site image = ${user.image}. The image should be hosted on Docusaurus site, in /static/img/users/ folder, and not use remote http or https urls`,
`Bad user site image = ${user.image}. The image should be hosted on Docusaurus site, in /static/img/users/ folder, and not use remote HTTP or HTTPS URLs`,
);
}
});
Expand Down
4 changes: 2 additions & 2 deletions website/docs/api/docusaurus.config.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ module.exports = {

- Type: `boolean`

This option adds `<meta name="robots" content="noindex">` in pages, to tell search engines to avoid indexing your site (more information [here](https://moz.com/learn/seo/robots-meta-directives)).
This option adds `<meta name="robots" content="noindex, nofollow">` in pages, to tell search engines to avoid indexing your site (more information [here](https://moz.com/learn/seo/robots-meta-directives)).

Example:

```js title="docusaurus.config.js"
module.exports = {
noIndex: true, // Defaults to false
noIndex: true, // Defaults to `false`
};
```

Expand Down
12 changes: 9 additions & 3 deletions website/docs/lifecycle-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,11 @@ You may use them to return your webpack configures conditionally.

For example, this plugin below modify the webpack config to transpile `.foo` file.

```js {4-11} title="docusaurus-plugin/src/index.js"
```js title="docusaurus-plugin/src/index.js"
module.exports = function (context, options) {
return {
name: 'custom-docusaurus-plugin',
// highlight-start
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More flexible way to keep highlighted proper lines.

configureWebpack(config, isServer, utils) {
const {getCacheLoader} = utils;
return {
Expand All @@ -316,6 +317,7 @@ module.exports = function (context, options) {
},
};
},
// highlight-end
};
};
```
Expand All @@ -326,14 +328,16 @@ We merge the Webpack configuration parts of plugins into the global Webpack conf

It is possible to specify the merge strategy. For example, if you want a webpack rule to be prepended instead of appended:

```js {4-11} title="docusaurus-plugin/src/index.js"
```js title="docusaurus-plugin/src/index.js"
module.exports = function (context, options) {
return {
name: 'custom-docusaurus-plugin',
configureWebpack(config, isServer, utils) {
return {
// highlight-start
mergeStrategy: {'module.rules': 'prepend'},
module: {rules: [myRuleToPrepend]},
// highlight-end
};
},
};
Expand Down Expand Up @@ -433,10 +437,11 @@ interface HtmlTagObject {

Example:

```js {4-28} title="docusaurus-plugin/src/index.js"
```js title="docusaurus-plugin/src/index.js"
module.exports = function (context, options) {
return {
name: 'docusaurus-plugin',
// highlight-start
injectHtmlTags() {
return {
headTags: [
Expand All @@ -460,6 +465,7 @@ module.exports = function (context, options) {
postBodyTags: [`<div> This is post body </div>`],
};
},
// highlight-end
};
};
```
Expand Down
12 changes: 9 additions & 3 deletions website/docs/theme-classic.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,12 @@ You can add items to the navbar via `themeConfig.navbar.items`.

By default, Navbar items are regular links (internal or external).

```js {5-15} title="docusaurus.config.js"
```js title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
navbar: {
// highlight-start
items: [
{
// Client-side routing, used for navigating within the website.
Expand All @@ -220,6 +221,7 @@ module.exports = {
},
// ... other items
],
// highlight-end
},
// ...
},
Expand Down Expand Up @@ -266,18 +268,20 @@ module.exports = {

If you want to link to a specific doc, this special navbar item type will render the link to the doc of the provided `docId`. It will get the class `navbar__link--active` as long as you browse a doc of the same sidebar.

```js {5-10} title="docusaurus.config.js"
```js title="docusaurus.config.js"
module.exports = {
themeConfig: {
navbar: {
items: [
// highlight-start
{
type: 'doc',
position: 'left',
docId: 'introduction',
label: 'Docs',
activeSidebarClassName: 'navbar__link--active',
},
// highlight-end
],
},
},
Expand Down Expand Up @@ -314,17 +318,19 @@ module.exports = {

If you use docs with versioning, this special navbar item type will link to the active/browsed version of your doc (depends on the current url), and fallback to the latest version.

```js {5-10} title="docusaurus.config.js"
```js title="docusaurus.config.js"
module.exports = {
themeConfig: {
navbar: {
items: [
// highlight-start
{
type: 'docsVersion',
position: 'left',
// to: "/path // by default, link to active/latest version
// label: "label" // by default, show active/latest version label
},
// highlight-end
],
},
},
Expand Down
2 changes: 1 addition & 1 deletion website/src/data/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ users.forEach((user) => {
(user.preview.startsWith('http') || user.preview.startsWith('//')))
) {
throw new Error(
`Bad user site image preview = ${user.preview}. The image should be hosted on Docusaurus site, and not use remote http or https urls`,
`Bad user site image preview = ${user.preview}. The image should be hosted on Docusaurus site, and not use remote HTTP or HTTPS URLs`,
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion website/static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"theme_color": "#2196f3",
"background_color": "#424242",
"display": "standalone",
"scope": "",
"scope": "./",
"start_url": "./index.html",
"icons": [
{
Expand Down