diff --git a/app/components/GiscusComments.tsx b/app/components/GiscusComments.tsx
new file mode 100644
index 0000000..5883c78
--- /dev/null
+++ b/app/components/GiscusComments.tsx
@@ -0,0 +1,28 @@
+'use client';
+
+import Giscus from '@giscus/react';
+
+interface GiscusCommentsProps {
+ className?: string;
+}
+
+export function GiscusComments({ className }: GiscusCommentsProps) {
+ return (
+
+
+
+ );
+}
diff --git a/app/docs/[...slug]/page.tsx b/app/docs/[...slug]/page.tsx
index 2bce4e8..f243b8a 100644
--- a/app/docs/[...slug]/page.tsx
+++ b/app/docs/[...slug]/page.tsx
@@ -3,6 +3,7 @@ import { DocsPage, DocsBody } from "fumadocs-ui/page";
import { notFound } from "next/navigation";
import type { Metadata } from "next";
import { getMDXComponents } from "@/mdx-components";
+import { GiscusComments } from "@/app/components/GiscusComments";
interface Param {
params: Promise<{
@@ -27,6 +28,9 @@ export default async function DocPage({ params }: Param) {
{page.data.title}
+
);
diff --git a/app/docs/ai/index.mdx b/app/docs/ai/index.mdx
index 465f03d..6650b6a 100644
--- a/app/docs/ai/index.mdx
+++ b/app/docs/ai/index.mdx
@@ -25,5 +25,3 @@ tags:
- 生成模型:Diffusion Models
- 方法论学习:科研指南、论文阅读
- 杂项工具:开发工具、平台使用
-
-> 注意:论文合集可邀请到 Zotero 协作;“TODO” 代表待施工项目。
diff --git a/app/docs/layout.tsx b/app/docs/layout.tsx
index f3b70eb..b164650 100644
--- a/app/docs/layout.tsx
+++ b/app/docs/layout.tsx
@@ -3,17 +3,66 @@ import { DocsLayout } from "fumadocs-ui/layouts/docs";
import { baseOptions } from "@/lib/layout.shared";
import type { ReactNode } from "react";
import { DocsRouteFlag } from "@/app/components/RouteFlags";
+import type { PageTree } from "fumadocs-core/server";
+
+function pruneEmptyFolders(root: PageTree.Root): PageTree.Root {
+ const transformNode = (node: PageTree.Node): PageTree.Node | null => {
+ if (node.type === "folder") {
+ const transformedChildren = node.children
+ .map(transformNode)
+ .filter((child): child is PageTree.Node => child !== null);
+
+ const index = node.index ? { ...node.index } : undefined;
+
+ if (transformedChildren.length > 0) {
+ return {
+ ...node,
+ index,
+ children: transformedChildren,
+ };
+ }
+
+ if (index) {
+ return { ...index };
+ }
+
+ return null;
+ }
+
+ if (node.type === "separator") {
+ return { ...node };
+ }
+
+ return { ...node };
+ };
+
+ const transformRoot = (node: PageTree.Root): PageTree.Root => {
+ const children = node.children
+ .map(transformNode)
+ .filter((child): child is PageTree.Node => child !== null);
+
+ return {
+ ...node,
+ children,
+ fallback: node.fallback ? transformRoot(node.fallback) : undefined,
+ };
+ };
+
+ return transformRoot(root);
+}
export default function Layout({ children }: { children: ReactNode }) {
+ const tree = pruneEmptyFolders(source.pageTree);
+
return (
<>
{/* Add a class on while in docs to adjust global backgrounds */}