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 ( -
{description}
-{description}
+
- Published on {formatDate2(date)}
+ {docuConfig.repository?.editLink &&
+ Published on {formatDate2(date)}
- )} + )}