From eefc0d11163b58f5fb8348da942972a6e5ccdb6b Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Wed, 18 Dec 2024 14:19:54 +0800 Subject: [PATCH 1/4] exports `convertToPageMap`, `mergeMetaWithPageMap`, `normalizePageMap`, `evaluate` from nextra --- .changeset/fast-drinks-itch.md | 5 +++++ packages/components/src/server/index.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/fast-drinks-itch.md diff --git a/.changeset/fast-drinks-itch.md b/.changeset/fast-drinks-itch.md new file mode 100644 index 000000000..d5001d1b2 --- /dev/null +++ b/.changeset/fast-drinks-itch.md @@ -0,0 +1,5 @@ +--- +'@theguild/components': patch +--- + +exports `convertToPageMap`, `mergeMetaWithPageMap`, `normalizePageMap`, `evaluate` from nextra diff --git a/packages/components/src/server/index.ts b/packages/components/src/server/index.ts index ea186a635..ad75b93f9 100644 --- a/packages/components/src/server/index.ts +++ b/packages/components/src/server/index.ts @@ -5,7 +5,14 @@ export { MDXRemote } from 'nextra/mdx-remote'; export { fetchFilePathsFromGitHub } from 'nextra/fetch-filepaths-from-github'; export { compileMdx } from 'nextra/compile'; -export { getPageMap, createIndexPage } from 'nextra/page-map'; +export { + getPageMap, + createIndexPage, + convertToPageMap, + mergeMetaWithPageMap, + normalizePageMap, +} from 'nextra/page-map'; +export { evaluate } from 'nextra/evaluate'; export { fetchPackageInfo } from './npm.js'; export { sharedMetaItems } from './shared-meta-items'; From e56d838f33e9e66be0ce4c87af660634fe865152 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Wed, 18 Dec 2024 14:42:11 +0800 Subject: [PATCH 2/4] add optional pageMap for guild layout --- packages/components/src/server/theme-layout.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/components/src/server/theme-layout.tsx b/packages/components/src/server/theme-layout.tsx index 73a7c8b93..d3fccb8ac 100644 --- a/packages/components/src/server/theme-layout.tsx +++ b/packages/components/src/server/theme-layout.tsx @@ -1,5 +1,6 @@ import { ComponentProps, FC, ReactNode } from 'react'; import { Metadata } from 'next'; +import { PageMapItem } from 'nextra'; import { Layout, Navbar } from 'nextra-theme-docs'; import { Head } from 'nextra/components'; import { getPageMap } from 'nextra/page-map'; @@ -72,6 +73,7 @@ export const GuildLayout: FC<{ * Nextra's Docs Theme `` component props */ navbarProps: NavbarProps; + pageMap?: PageMapItem[]; }> = async ({ children, websiteName, @@ -81,8 +83,9 @@ export const GuildLayout: FC<{ logo, layoutProps, navbarProps, + ...props }) => { - const [meta, ...pageMap] = await getPageMap(); + const [meta, ...pageMap] = props.pageMap || (await getPageMap()); const pageMapWithCompanyMenu = [ { From b1f7b0e0135495aab7fa0bc97890c2d1744d73db Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Wed, 18 Dec 2024 17:35:52 +0800 Subject: [PATCH 3/4] do not index code blocks --- packages/components/src/server/next.config.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/components/src/server/next.config.ts b/packages/components/src/server/next.config.ts index 286c14476..511faea0d 100644 --- a/packages/components/src/server/next.config.ts +++ b/packages/components/src/server/next.config.ts @@ -75,9 +75,6 @@ const rehypeCheckFrontMatter: Plugin<[], any> = () => (ast, file) => { export const defaultNextraOptions: NextraConfig = { defaultShowCopyCode: true, whiteListTagsStyling: ['iframe', 'video', 'source'], - search: { - codeblocks: true, - }, mdxOptions: { // Check front matter only in production (when Webpack is used) // Should be rehype since frontMatter is attached in remark plugins From 30b07f022935f333eb0a92cb1fb62d2638809cb3 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Wed, 18 Dec 2024 18:15:22 +0800 Subject: [PATCH 4/4] do not index code blocks! --- packages/components/src/server/next.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/components/src/server/next.config.ts b/packages/components/src/server/next.config.ts index 511faea0d..9897d8015 100644 --- a/packages/components/src/server/next.config.ts +++ b/packages/components/src/server/next.config.ts @@ -75,6 +75,9 @@ const rehypeCheckFrontMatter: Plugin<[], any> = () => (ast, file) => { export const defaultNextraOptions: NextraConfig = { defaultShowCopyCode: true, whiteListTagsStyling: ['iframe', 'video', 'source'], + search: { + codeblocks: false, + }, mdxOptions: { // Check front matter only in production (when Webpack is used) // Should be rehype since frontMatter is attached in remark plugins