-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Description
🐛 Bug Report
In the documentation, it mentions that preset classic can support blog-only mode seamlessly: https://v2.docusaurus.io/docs/blog#blog-only-mode
However, several changes in alpha-62 makes it much harder in two possible scenarios of blog-only mode usage:
-
alpha-62 will start complain and abort when docs folder or
sidebars.jsonis missing. This means that if we are using preset-classic and have no docs, build cannot succeed. The workaround might be add some dummy docs. -
alpha-62 introduces some hooks from docs plugin. If we don't use preset-classic and only use blog plugin and theme-classic, build will fail because
@theme/hooksonly exist in docs plugin but some components in theme-classic import it:docusaurus/packages/docusaurus-theme-classic/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx
Lines 10 to 14 in 4f448bd
import { useVersions, useLatestVersion, useActiveDocContext, } from '@theme/hooks/useDocs';
To workaround the issue, I created a dummy useDocs.js in src/theme/hooks in my website:
but ideally blog-only mode can just work without this kind of hacks.
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
(Write your steps here:)
npx @docusaurus/init@next init test classic- Setup blog only mode according to https://v2.docusaurus.io/docs/blog#blog-only-mode
yarn start. It failed. SeeActual Behaviorsection below.
Expected behavior
Blog only mode should work out-of-the-box.
Actual Behavior
Scenario 1: (with preset-classic)
module.exports = {
// ...
presets: [
[
'@docusaurus/preset-classic',
{
blog: {
path: './blog',
routeBasePath: '/', // Set this value to '/'.
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
},
],
],
};➜ test yarn start
yarn run v1.22.5
$ docusaurus start
Starting the development server...
Error: The docs folder does not exist for version [current]. A docs folder is expected to be found at /Users/sam/Downloads/test/docs
at checkVersionMetadataPaths (/Users/sam/Downloads/test/node_modules/@docusaurus/plugin-content-docs/lib/versions.js:132:15)
at Array.forEach (<anonymous>)
at Object.readVersionsMetadata (/Users/sam/Downloads/test/node_modules/@docusaurus/plugin-content-docs/lib/versions.js:171:22)
at pluginContentDocs (/Users/sam/Downloads/test/node_modules/@docusaurus/plugin-content-docs/lib/index.js:27:41)
at /Users/sam/Downloads/test/node_modules/@docusaurus/core/lib/server/plugins/init.js:72:48
at Array.map (<anonymous>)
at Object.initPlugins [as default] (/Users/sam/Downloads/test/node_modules/@docusaurus/core/lib/server/plugins/init.js:27:10)
at Object.loadPlugins (/Users/sam/Downloads/test/node_modules/@docusaurus/core/lib/server/plugins/index.js:49:35)
at Object.load (/Users/sam/Downloads/test/node_modules/@docusaurus/core/lib/server/index.js:78:74)
at start (/Users/sam/Downloads/test/node_modules/@docusaurus/core/lib/commands/start.js:44:34)
at /Users/sam/Downloads/test/node_modules/@docusaurus/core/bin/docusaurus.js:73:5
at Command.<anonymous> (/Users/sam/Downloads/test/node_modules/@docusaurus/core/bin/docusaurus.js:152:23)
at Command.listener (/Users/sam/Downloads/test/node_modules/commander/index.js:370:29)
at Command.emit (events.js:315:20)
at Command.parseArgs (/Users/sam/Downloads/test/node_modules/commander/index.js:892:12)
at Command.parse (/Users/sam/Downloads/test/node_modules/commander/index.js:642:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Scenario 2: (with @docusaurus/theme-classic + @docusaurus/plugin-content-blog)
module.exports = {
// ...
themes: [
[
require.resolve('@docusaurus/theme-classic'),
{ customCss: require.resolve('./src/css/custom.css') },
],
],
plugins: [
[
require.resolve('@docusaurus/plugin-content-blog'),
{
path: './blog',
routeBasePath: '/', // Set this value to '/'.
},
],
],
};./node_modules/@docusaurus/theme-classic/lib/theme/NavbarItem/DocsVersionNavbarItem.js
Module not found: Can't resolve '@theme/hooks/useDocs' in '/Users/sam/Downloads/test/node_modules/@docusaurus/theme-classic/lib/theme/NavbarItem'
Your Environment
- Docusaurus version used: v2-alpha-62
- Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node.js 12
- Operating system and version (desktop or mobile): desktop