From ab755844a36399205b0a651534fc6a9ace0ac480 Mon Sep 17 00:00:00 2001 From: gitfromwildan <> Date: Tue, 10 Mar 2026 01:38:58 +0700 Subject: [PATCH] refactor: Migrate documentation content, rebuild UI components, and update core architecture. --- .gitignore | 7 +- Dockerfile | 19 +- app/docs/[[...slug]]/page.tsx | 112 +- app/docs/layout.tsx | 15 +- app/layout.tsx | 22 +- app/page.tsx | 16 +- bun.lock | 1462 +++ ...context-popover.tsx => ContextPopover.tsx} | 9 +- components/DocSearch.tsx | 31 +- ...docs-breadcrumb.tsx => DocsBreadcrumb.tsx} | 7 +- components/DocsMenu.tsx | 63 + components/DocsNavbar.tsx | 44 + components/DocsSidebar.tsx | 205 + ...{edit-on-github.tsx => EditWithGithub.tsx} | 0 components/Github.tsx | 26 + components/GithubStart.tsx | 44 - .../{scroll-to-top.tsx => ScrollToTop.tsx} | 25 +- components/SearchBox.tsx | 39 + components/SearchContext.tsx | 47 + components/SearchModal.tsx | 156 +- components/SearchTrigger.tsx | 35 +- components/Sponsor.tsx | 4 +- .../theme-provider.tsx => ThemeProvider.tsx} | 0 .../{theme-toggle.tsx => ThemeToggle.tsx} | 20 +- components/TocObserver.tsx | 197 + components/contexts/AccordionContext.ts | 4 - components/docs-menu.tsx | 37 - components/footer.tsx | 28 +- components/leftbar.tsx | 116 +- components/markdown/AccordionContext.tsx | 21 + components/markdown/AccordionGroupMdx.tsx | 33 +- components/markdown/AccordionMdx.tsx | 109 +- components/markdown/CardMdx.tsx | 8 +- components/markdown/CopyMdx.tsx | 2 +- components/markdown/FileTreeMdx.tsx | 8 +- components/markdown/ImageMdx.tsx | 136 +- components/markdown/NoteMdx.tsx | 75 +- components/markdown/PreMdx.tsx | 4 +- components/markdown/ReleaseMdx.tsx | 30 +- components/markdown/TooltipsMdx.tsx | 2 +- components/mob-toc.tsx | 128 - components/navbar.tsx | 177 +- components/pagination.tsx | 4 +- components/search.tsx | 55 - components/sublink.tsx | 28 +- components/toc-observer.tsx | 254 - components/toc.tsx | 30 +- components/typography.tsx | 2 +- components/ui/icon-cloud.tsx | 353 + components/ui/scroll-area.tsx | 4 +- components/ui/sheet.tsx | 8 +- components/ui/table.tsx | 6 +- components/ui/tabs.tsx | 2 +- components/ui/toggle.tsx | 6 +- contents/docs/api-reference/meta.json | 5 - contents/docs/changelog/index.mdx | 16 - .../docs/developer/api/licensing/index.mdx | 87 - contents/docs/developer/overview/index.mdx | 17 - .../getting-started/development/index.mdx | 63 - contents/docs/getting-started/meta.json | 7 - contents/docs/hooks/meta.json | 9 - contents/docs/meta.json | 9 - contents/docs/resources/faq/index.mdx | 114 - .../docs/resources/troubleshooting/index.mdx | 175 - .../builder/header-footer.mdx | 0 {contents/docs => docs}/builder/index.mdx | 0 .../index.mdx => docs/builder/sections.mdx | 0 .../builder/special-pages.mdx | 0 .../builder/visual-editor.mdx | 0 .../configuration/appearance.mdx | 0 .../index.mdx => docs/configuration/email.mdx | 0 .../configuration/general.mdx | 0 .../docs => docs}/configuration/index.mdx | 0 .../configuration/licensing.mdx | 0 .../configuration/modules.mdx | 0 .../configuration/payment-shipping.mdx | 0 .../configuration/security.mdx | 0 .../configuration/spa-mode.mdx | 0 .../developer/addons/bridge-pattern.mdx | 0 .../developer/addons/custom-channels.mdx | 0 .../developer/addons/module-integration.mdx | 0 .../developer/addons/page-templates.mdx | 0 .../developer/addons/react-integration.mdx | 0 .../developer/api/licensing.mdx | 0 docs/developer/overview.mdx | 20 + .../developer/software-updates/index.mdx | 0 .../software-updates/store-owner.mdx | 0 .../index.mdx => docs/features/checkout.mdx | 0 docs/features/index.mdx | 9 + .../shop/index.mdx => docs/features/shop.mdx | 0 .../index.mdx => docs/features/shortcodes.mdx | 0 .../getting-started/installation.mdx | 0 .../getting-started/introduction.mdx | 0 .../getting-started/quick-setup.mdx | 0 .../getting-started/quick-start-guide.mdx | 0 .../index.mdx => docs/hooks/frontend.mdx | 0 {contents/docs => docs}/hooks/index.mdx | 0 .../index.mdx => docs/hooks/newsletter.mdx | 0 .../index.mdx => docs/hooks/notifications.mdx | 2 - .../index.mdx => docs/hooks/subscriptions.mdx | 0 {contents/docs => docs}/licensing/meta.json | 0 .../licensing/oauth-flow/index.mdx | 0 .../index.mdx => docs/marketing/coupons.mdx | 0 {contents/docs => docs}/marketing/index.mdx | 0 .../marketing/newsletter.mdx | 0 .../index.mdx => docs/marketing/wishlist.mdx | 0 .../index.mdx => docs/resources/changelog.mdx | 0 docs/resources/faq.mdx | 114 + docs/resources/troubleshooting.mdx | 198 + .../index.mdx => docs/store/customers.mdx | 0 {contents/docs => docs}/store/index.mdx | 0 .../orders/index.mdx => docs/store/orders.mdx | 0 .../index.mdx => docs/store/products.mdx | 0 .../index.mdx => docs/store/subscriptions.mdx | 0 docu.json | 121 +- eslint.config.mjs | 47 +- hooks/useActiveSection.ts | 78 +- hooks/useScrollPosition.ts | 30 +- lib/markdown.ts | 118 +- lib/{routes-config.ts => routes.ts} | 0 lib/search/algolia.ts | 5 + lib/search/built-in.ts | 43 + lib/search/config.ts | 7 + lib/toc.ts | 1 + lib/utils.ts | 67 +- next.config.mjs | 23 +- package-lock.json | 10850 ---------------- package.json | 6 +- styles/algolia.css | 47 +- styles/globals.css | 1 - styles/{syntax.css => override.css} | 124 +- tailwind.config.ts | 121 +- 132 files changed, 3947 insertions(+), 12862 deletions(-) create mode 100644 bun.lock rename components/{context-popover.tsx => ContextPopover.tsx} (92%) rename components/{docs-breadcrumb.tsx => DocsBreadcrumb.tsx} (85%) create mode 100644 components/DocsMenu.tsx create mode 100644 components/DocsNavbar.tsx create mode 100644 components/DocsSidebar.tsx rename components/{edit-on-github.tsx => EditWithGithub.tsx} (100%) create mode 100644 components/Github.tsx delete mode 100644 components/GithubStart.tsx rename components/{scroll-to-top.tsx => ScrollToTop.tsx} (70%) create mode 100644 components/SearchBox.tsx create mode 100644 components/SearchContext.tsx rename components/{contexts/theme-provider.tsx => ThemeProvider.tsx} (100%) rename components/{theme-toggle.tsx => ThemeToggle.tsx} (77%) create mode 100644 components/TocObserver.tsx delete mode 100644 components/contexts/AccordionContext.ts delete mode 100644 components/docs-menu.tsx create mode 100644 components/markdown/AccordionContext.tsx delete mode 100644 components/mob-toc.tsx delete mode 100644 components/search.tsx delete mode 100644 components/toc-observer.tsx create mode 100644 components/ui/icon-cloud.tsx delete mode 100644 contents/docs/api-reference/meta.json delete mode 100644 contents/docs/changelog/index.mdx delete mode 100644 contents/docs/developer/api/licensing/index.mdx delete mode 100644 contents/docs/developer/overview/index.mdx delete mode 100644 contents/docs/getting-started/development/index.mdx delete mode 100644 contents/docs/getting-started/meta.json delete mode 100644 contents/docs/hooks/meta.json delete mode 100644 contents/docs/meta.json delete mode 100644 contents/docs/resources/faq/index.mdx delete mode 100644 contents/docs/resources/troubleshooting/index.mdx rename contents/docs/builder/header-footer/index.mdx => docs/builder/header-footer.mdx (100%) rename {contents/docs => docs}/builder/index.mdx (100%) rename contents/docs/builder/sections/index.mdx => docs/builder/sections.mdx (100%) rename contents/docs/builder/special-pages/index.mdx => docs/builder/special-pages.mdx (100%) rename contents/docs/builder/visual-editor/index.mdx => docs/builder/visual-editor.mdx (100%) rename contents/docs/configuration/appearance/index.mdx => docs/configuration/appearance.mdx (100%) rename contents/docs/configuration/email/index.mdx => docs/configuration/email.mdx (100%) rename contents/docs/configuration/general/index.mdx => docs/configuration/general.mdx (100%) rename {contents/docs => docs}/configuration/index.mdx (100%) rename contents/docs/configuration/licensing/index.mdx => docs/configuration/licensing.mdx (100%) rename contents/docs/configuration/modules/index.mdx => docs/configuration/modules.mdx (100%) rename contents/docs/configuration/payment-shipping/index.mdx => docs/configuration/payment-shipping.mdx (100%) rename contents/docs/configuration/security/index.mdx => docs/configuration/security.mdx (100%) rename contents/docs/configuration/spa-mode/index.mdx => docs/configuration/spa-mode.mdx (100%) rename contents/docs/developer/addons/bridge-pattern/index.mdx => docs/developer/addons/bridge-pattern.mdx (100%) rename contents/docs/developer/addons/custom-channels/index.mdx => docs/developer/addons/custom-channels.mdx (100%) rename contents/docs/developer/addons/module-integration/index.mdx => docs/developer/addons/module-integration.mdx (100%) rename contents/docs/developer/addons/page-templates/index.mdx => docs/developer/addons/page-templates.mdx (100%) rename contents/docs/developer/addons/react-integration/index.mdx => docs/developer/addons/react-integration.mdx (100%) rename contents/docs/api-reference/licensing/index.mdx => docs/developer/api/licensing.mdx (100%) create mode 100644 docs/developer/overview.mdx rename {contents/docs => docs}/developer/software-updates/index.mdx (100%) rename contents/docs/developer/software-updates/store-owner/index.mdx => docs/developer/software-updates/store-owner.mdx (100%) rename contents/docs/features/checkout/index.mdx => docs/features/checkout.mdx (100%) create mode 100644 docs/features/index.mdx rename contents/docs/features/shop/index.mdx => docs/features/shop.mdx (100%) rename contents/docs/features/shortcodes/index.mdx => docs/features/shortcodes.mdx (100%) rename contents/docs/getting-started/installation/index.mdx => docs/getting-started/installation.mdx (100%) rename contents/docs/getting-started/introduction/index.mdx => docs/getting-started/introduction.mdx (100%) rename contents/docs/getting-started/quick-setup/index.mdx => docs/getting-started/quick-setup.mdx (100%) rename contents/docs/getting-started/quick-start-guide/index.mdx => docs/getting-started/quick-start-guide.mdx (100%) rename contents/docs/hooks/frontend/index.mdx => docs/hooks/frontend.mdx (100%) rename {contents/docs => docs}/hooks/index.mdx (100%) rename contents/docs/hooks/newsletter/index.mdx => docs/hooks/newsletter.mdx (100%) rename contents/docs/hooks/notifications/index.mdx => docs/hooks/notifications.mdx (98%) rename contents/docs/hooks/subscriptions/index.mdx => docs/hooks/subscriptions.mdx (100%) rename {contents/docs => docs}/licensing/meta.json (100%) rename {contents/docs => docs}/licensing/oauth-flow/index.mdx (100%) rename contents/docs/marketing/coupons/index.mdx => docs/marketing/coupons.mdx (100%) rename {contents/docs => docs}/marketing/index.mdx (100%) rename contents/docs/marketing/newsletter/index.mdx => docs/marketing/newsletter.mdx (100%) rename contents/docs/marketing/wishlist/index.mdx => docs/marketing/wishlist.mdx (100%) rename contents/docs/resources/changelog/index.mdx => docs/resources/changelog.mdx (100%) create mode 100644 docs/resources/faq.mdx create mode 100644 docs/resources/troubleshooting.mdx rename contents/docs/store/customers/index.mdx => docs/store/customers.mdx (100%) rename {contents/docs => docs}/store/index.mdx (100%) rename contents/docs/store/orders/index.mdx => docs/store/orders.mdx (100%) rename contents/docs/store/products/index.mdx => docs/store/products.mdx (100%) rename contents/docs/store/subscriptions/index.mdx => docs/store/subscriptions.mdx (100%) rename lib/{routes-config.ts => routes.ts} (100%) create mode 100644 lib/search/algolia.ts create mode 100644 lib/search/built-in.ts create mode 100644 lib/search/config.ts delete mode 100644 package-lock.json rename styles/{syntax.css => override.css} (57%) diff --git a/.gitignore b/.gitignore index df112b8..17d6cb2 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ out/ .env.development .env.test .env.production +.crawler # Debug logs npm-debug.log* @@ -61,12 +62,6 @@ Thumbs.db *.tsbuildinfo next-env.d.ts -# Package managers -# package-lock.json -# yarn.lock -# bun.lock -# pnpm-lock.yaml - # Build outputs .next out diff --git a/Dockerfile b/Dockerfile index 89597b8..20b541a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,12 +6,16 @@ FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app +# Install Bun +RUN npm install -g bun + # Install dependencies based on the preferred package manager -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* bun.lock* ./ RUN \ - if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + if [ -f bun.lock ]; then bun install --frozen-lockfile; \ + elif [ -f yarn.lock ]; then yarn --frozen-lockfile; \ elif [ -f package-lock.json ]; then npm ci; \ - elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ else echo "Lockfile not found." && exit 1; \ fi @@ -27,7 +31,13 @@ COPY . . # Uncomment the following line in case you want to disable telemetry during the build. ENV NEXT_TELEMETRY_DISABLED 1 -RUN npm run build +# Install Bun for build stage if needed (depending on script) +RUN npm install -g bun + +RUN \ + if [ -f bun.lock ]; then bun run build; \ + else npm run build; \ + fi # Production image, copy all the files and run next FROM base AS runner @@ -57,3 +67,4 @@ ENV PORT 3000 ENV HOSTNAME "0.0.0.0" CMD ["node", "server.js"] + diff --git a/app/docs/[[...slug]]/page.tsx b/app/docs/[[...slug]]/page.tsx index 47a49cc..fc636bb 100644 --- a/app/docs/[[...slug]]/page.tsx +++ b/app/docs/[[...slug]]/page.tsx @@ -1,46 +1,42 @@ -import { notFound } from "next/navigation"; -import { getDocsForSlug, getDocsTocs } from "@/lib/markdown"; -import DocsBreadcrumb from "@/components/docs-breadcrumb"; -import Pagination from "@/components/pagination"; -import Toc from "@/components/toc"; -import { Typography } from "@/components/typography"; -import EditThisPage from "@/components/edit-on-github"; -import { formatDate2 } from "@/lib/utils"; -import docuConfig from "@/docu.json"; -import MobToc from "@/components/mob-toc"; +import { notFound } from "next/navigation" +import { getDocsForSlug, getDocsTocs } from "@/lib/markdown" +import DocsBreadcrumb from "@/components/DocsBreadcrumb" +import Pagination from "@/components/pagination" +import Toc from "@/components/toc" +import { Typography } from "@/components/typography" +import EditThisPage from "@/components/EditWithGithub" +import { formatDate2 } from "@/lib/utils" +import docuConfig from "@/docu.json" +import MobToc from "@/components/DocsSidebar" -const { meta } = docuConfig; +const { meta } = docuConfig type PageProps = { params: Promise<{ - slug: string[]; - }>; -}; + slug: string[] + }> +} // Function to generate metadata dynamically export async function generateMetadata(props: PageProps) { - const params = await props.params; + const params = await props.params - const { - slug = [] - } = params; + const { slug = [] } = params - const pathName = slug.join("/"); - const res = await getDocsForSlug(pathName); + const pathName = slug.join("/") + const res = await getDocsForSlug(pathName) if (!res) { return { title: "Page Not Found", description: "The requested page was not found.", - }; + } } - const { title, description, image } = res.frontmatter; + const { title, description, image } = res.frontmatter // Absolute URL for og:image - const ogImage = image - ? `${meta.baseURL}/images/${image}` - : `${meta.baseURL}/images/og-image.png`; + const ogImage = image ? `${meta.baseURL}/images/${image}` : `${meta.baseURL}/images/og-image.png` return { title: `${title}`, @@ -65,53 +61,49 @@ export async function generateMetadata(props: PageProps) { description, images: [ogImage], }, - }; + } } export default async function DocsPage(props: PageProps) { - const params = await props.params; + const params = await props.params - const { - slug = [] - } = params; + const { slug = [] } = params - const pathName = slug.join("/"); - const res = await getDocsForSlug(pathName); + const pathName = slug.join("/") + const res = await getDocsForSlug(pathName) - if (!res) notFound(); + if (!res) notFound() - const { title, description, image: _image, date } = res.frontmatter; - - // File path for edit link - const filePath = `contents/docs/${slug.join("/") || ""}/index.mdx`; - - const tocs = await getDocsTocs(pathName); + const { title, description, image: _image, date } = res.frontmatter + const filePath = res.filePath + const tocs = await getDocsTocs(pathName) return ( -
-
- - - -

{title}

-

{description}

-
{res.content}
-
+
+
+ + + +

{title}

+

{description}

+
{res.content}
+
- {docuConfig.repository?.editLink && } - {date && ( -

- Published on {formatDate2(date)} + {docuConfig.repository?.editLink && } + {date && ( +

+ Published on {formatDate2(date)}

- )} + )}
- -
+ + +
+
-
- ); + ) } diff --git a/app/docs/layout.tsx b/app/docs/layout.tsx index d949ff0..ec06a30 100644 --- a/app/docs/layout.tsx +++ b/app/docs/layout.tsx @@ -1,4 +1,6 @@ import { Leftbar } from "@/components/leftbar"; +import DocsNavbar from "@/components/DocsNavbar"; +import "@/styles/override.css"; export default function DocsLayout({ children, @@ -6,10 +8,15 @@ export default function DocsLayout({ children: React.ReactNode; }>) { return ( -
- -
- {children} +
+
+ +
+ +
+ {children} +
+
); diff --git a/app/layout.tsx b/app/layout.tsx index 79d3fb4..d60d324 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,14 +1,14 @@ import type { Metadata } from "next"; -import { ThemeProvider } from "@/components/contexts/theme-provider"; +import { ThemeProvider } from "@/components/ThemeProvider"; import { Navbar } from "@/components/navbar"; import { GeistSans } from "geist/font/sans"; import { GeistMono } from "geist/font/mono"; import { Footer } from "@/components/footer"; +import { SearchProvider } from "@/components/SearchContext"; import docuConfig from "@/docu.json"; -import { Toaster } from "@/components/ui/sonner"; import "@docsearch/css"; import "@/styles/algolia.css"; -import "@/styles/syntax.css"; +import "@/styles/override.css"; import "@/styles/globals.css"; const { meta } = docuConfig; @@ -35,6 +35,9 @@ const defaultMetadata: Metadata = { locale: "en_US", type: "website", }, + other: { + "algolia-site-verification": "6E413CE39E56BB62", + }, }; // Dynamic Metadata Getter @@ -86,12 +89,13 @@ export default function RootLayout({ enableSystem disableTransitionOnChange > - -
- {children} -
-