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(blog): improve doc global data hook error message + add doc warning to blogOnly mode #9839

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 10 additions & 3 deletions packages/docusaurus-plugin-content-docs/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,16 @@ export function useActiveVersion(
export function useActiveDocContext(
pluginId: string | undefined,
): ActiveDocContext {
const data = useDocsData(pluginId);
const {pathname} = useLocation();
return getActiveDocContext(data, pathname);
try {
const data = useDocsData(pluginId);
const {pathname} = useLocation();
return getActiveDocContext(data, pathname);
} catch (error) {
throw new Error(
'It seems that you are using a doc plugin feature while the doc plugin seems to be disabled in `docusaurus.config.js`.',
OzakIOne marked this conversation as resolved.
Show resolved Hide resolved
error as Error,
OzakIOne marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
/**
* Useful to say "hey, you are not on the latest docs version, please switch"
Expand Down
6 changes: 6 additions & 0 deletions website/docs/blog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@ Don't forget to delete the existing homepage at `./src/pages/index.js` or else t

:::

:::warning

Don't forget to delete element of type doc in `docusaurus.config.js` in the navbar for example or else Docusaurus will crash.
OzakIOne marked this conversation as resolved.
Show resolved Hide resolved

:::

:::tip

There's also a "Docs-only mode" for those who only want to use the docs. Read [Docs-only mode](./guides/docs/docs-introduction.mdx) for detailed instructions or a more elaborate explanation of `routeBasePath`.
Expand Down
Loading