From 6974d766d092d778c27ba1b7a46876cd379c4467 Mon Sep 17 00:00:00 2001 From: shenxianovo Date: Fri, 16 Oct 2026 09:53:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E5=8D=87=E7=BA=A7=20Fumadocs?= =?UTF-8?q?=20=E5=B9=B6=E5=A4=8D=E7=94=A8=E5=86=85=E7=BD=AE=E8=83=BD?= =?UTF-8?q?=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 +- app/[[...slug]]/page.tsx | 12 +- app/content.css | 5 - app/globals.css | 1 + app/sitemap.ts | 12 +- components/git-changelog.css | 87 ---- components/git-changelog.tsx | 8 - components/git-history-view.tsx | 150 ------- components/mdx.tsx | 3 +- components/page-view-options.tsx | 66 --- components/provider.tsx | 35 +- components/search.tsx | 12 +- docs/group/ani-key/activity/participants.mdx | 1 - docs/maintainer/contributing.mdx | 2 + lib/changelog.ts | 28 -- lib/git-history.d.mts | 9 - lib/git-history.mjs | 84 ---- lib/navigation.ts | 20 +- lib/people.d.ts | 8 +- lib/people.js | 22 +- lib/remark-search-anchors.mjs | 35 +- package.json | 14 +- pnpm-lock.yaml | 438 +++++++++---------- pnpm-workspace.yaml | 7 +- scripts/page-history.test.mjs | 60 +++ source.config.ts | 39 +- 26 files changed, 397 insertions(+), 775 deletions(-) delete mode 100644 components/git-changelog.css delete mode 100644 components/git-changelog.tsx delete mode 100644 components/git-history-view.tsx delete mode 100644 components/page-view-options.tsx delete mode 100644 lib/changelog.ts delete mode 100644 lib/git-history.d.mts delete mode 100644 lib/git-history.mjs create mode 100644 scripts/page-history.test.mjs diff --git a/README.md b/README.md index 75dcc69..7cf7e5e 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,12 @@ ## 本地开发 -需要 Node.js 24、pnpm 11。请完整克隆仓库(不要 shallow clone),以显示完整页面历史。 +需要 Node.js 24.14 或更新版本、pnpm 11。请完整克隆仓库(不要 shallow clone),以显示完整页面历史。 ```sh pnpm install --frozen-lockfile pnpm dev # http://localhost:3000 -pnpm check # 类型、静态构建与路由/资源/搜索定位检查 +pnpm check # 历史回归、类型、静态构建与路由/资源/搜索定位检查 pnpm preview # http://localhost:4173,预览 out/ 中的实际静态产物 ``` @@ -21,12 +21,12 @@ pnpm preview # http://localhost:4173,预览 out/ 中的实际静态产物 - `docs/**/*.mdx`:内容;原 Markdown 文件名/路由保留,Vue 片段已迁移为 React/MDX - `public/`:原有图片、PDF、视频、PDF.js 和独立历史页面,由 Next.js 直接读取,构建时原样输出到站点根目录 - `lib/navigation.json`:顶栏和按最长路径匹配的分区侧栏 -- `lib/git-history.mjs`:构建期读取页面历史 - `lib/people.js`、`lib/icons.js`:统一人员、头像、贡献者别名与社交图标 - `components/content.tsx`:聊天气泡、成员卡、团队页等 React 组件 -- `components/git-history-view.tsx`:页面完整 Git 历史、排序/展开、作者与共同作者 -- `source.config.ts`、`lib/remark-legacy-headings.mjs`:Fumadocs MDX 及历史标题锚点兼容 -- `scripts/`:仅保留发布产物检查;搜索由 Fumadocs 生成,站点地图由 Next.js 生成,本地静态预览使用 `serve` +- `source.config.ts`:Fumadocs MDX 配置;通过 `remarkGitChangelog` 自动追加贡献者和页面历史,并由 Fumadocs 导出页面更新时间 +- `components/provider.tsx`:通过 Fumadocs 翻译接口组合官方简体中文语言包和页面历史中文预设 +- `lib/remark-legacy-headings.mjs`:历史标题锚点兼容 +- `scripts/`:发布产物检查和页面历史接入回归测试;搜索由 Fumadocs 生成,站点地图由 Next.js 生成,本地静态预览使用 `serve` - `out/`:GitHub Pages 静态输出,包含站点地图、CNAME 和原有独立 HTML 存档;文章使用无 `.html` 后缀的地址 ## 投稿与维护 @@ -35,6 +35,8 @@ pnpm preview # http://localhost:4173,预览 out/ 中的实际静态产物 图片和附件直接维护在根目录 `public/`。构建检查当前静态页面的站内链接、资源地址和锚点,不依赖旧站迁移快照。 +页面历史直接使用 npm 发布的 `fumadocs-page-history`,无需本地补丁。本站在 `source.config.ts` 中通过 `getHistoryPaths` 显式关联迁移前的同路径 `.md` 文件,由包统一合并、去重、排序,不限制数量。迁移同时改写了 Vue/React 语法,部分文件未达到 Git 默认 50% 的重命名相似度阈值,显式路径用于补齐这部分记录。`scripts/page-history.test.mjs` 验证迁移前记录、建页及合并提交,以及复制模板不会混入其他页面的历史。 + ## 许可 本站内容采用[知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)许可。图片、文档等版权归原作者所有。 diff --git a/app/[[...slug]]/page.tsx b/app/[[...slug]]/page.tsx index 8f102ce..3779a48 100644 --- a/app/[[...slug]]/page.tsx +++ b/app/[[...slug]]/page.tsx @@ -2,16 +2,13 @@ import { notFound } from 'next/navigation'; import type { Metadata } from 'next'; import { DocsLayout } from '@fumadocs/base-ui/layouts/spacious'; import { HomeLayout } from '@fumadocs/base-ui/layouts/home'; -import { DocsPage, DocsBody, MarkdownCopyButton } from '@fumadocs/base-ui/layouts/spacious/page'; +import { DocsPage, DocsBody, MarkdownCopyButton, ViewOptionsPopover } from '@fumadocs/base-ui/layouts/spacious/page'; import { Heading } from '@fumadocs/base-ui/components/heading'; import { source, getCanonicalPath, getMarkdownPath } from '@/lib/source'; import { baseOptions } from '@/lib/layout.shared'; import { getSidebar, getPagination, sectionTabs } from '@/lib/navigation'; import { getMDXComponents } from '@/components/mdx'; import { TeamPageTitle } from '@/components/content'; -import { PageViewOptions } from '@/components/page-view-options'; -import { GitChangelog } from '@/components/git-changelog'; -import { shouldShowChangelog } from '@/lib/changelog'; import { CanonicalUrl } from '@/components/canonical-url'; import { Home } from '@/components/home'; import { SiteFooter } from '@/components/site-footer'; @@ -41,9 +38,9 @@ export default async function Page({ params }: Props) { if (data.layout === 'home') return <>; const MDX = data.body; const markdownUrl = getMarkdownPath(page.path); - const pageActions =
+ const pageActions = data.layout === 'page' && page.path.startsWith('about/hq/') ? null :
-
; @@ -55,12 +52,11 @@ export default async function Page({ params }: Props) {
{content}
; const outline = data.outline; - const toc = [...data.toc, ...(shouldShowChangelog(data) ? [{ title: '页面历史', url: '#页面历史', depth: 2 }] : [])].filter((entry) => entry.depth >= (Array.isArray(outline) ? outline[0] : 2) && entry.depth <= (Array.isArray(outline) ? outline[1] : typeof outline === 'number' ? outline : outline === 'deep' ? 6 : 2)); + const toc = data.toc.filter((entry) => entry.depth >= (Array.isArray(outline) ? outline[0] : 2) && entry.depth <= (Array.isArray(outline) ? outline[1] : typeof outline === 'number' ? outline : outline === 'deep' ? 6 : 2)); return
{content}
- 回到顶部 ↑
diff --git a/app/content.css b/app/content.css index 106f667..ff31865 100644 --- a/app/content.css +++ b/app/content.css @@ -1,10 +1,5 @@ /* Preserved page-specific styles from the VitePress content. */ -/* Migrated from docs/group/ani-key/activity/participants.md. */ -.ak-no-changelog{ display:none; } -.ak-no-changelog ~ h2, -.ak-no-changelog ~ div{ display:none !important; } - /* Migrated from docs/group/ani-key/index.md. */ /* 仅保留头像墙样式 */ .ak-hero__pics{ diff --git a/app/globals.css b/app/globals.css index 5226dfc..519d7ec 100644 --- a/app/globals.css +++ b/app/globals.css @@ -2,6 +2,7 @@ @import '@fumadocs/base-ui/css/neutral.css'; @import '@fumadocs/base-ui/css/preset.css'; @import '@fumadocs/base-ui/css/generated/spacious.css'; +@import 'fumadocs-page-history/css/preset.css'; :root { --color-fd-primary: #3451b2; diff --git a/app/sitemap.ts b/app/sitemap.ts index 933d03a..31c055c 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -1,16 +1,12 @@ import type { MetadataRoute } from 'next'; import { source, getCanonicalPath } from '@/lib/source'; -import { readPageHistory } from '@/lib/git-history.mjs'; import { site } from '@/lib/site'; export const dynamic = 'force-static'; export default function sitemap(): MetadataRoute.Sitemap { - return source.getPages().map(page => { - const lastModified = readPageHistory(`docs/${page.path}`)[0]?.date; - return { - url: `${site.url}${getCanonicalPath(page.path)}`, - ...(lastModified ? { lastModified } : {}), - }; - }); + return source.getPages().map(page => ({ + url: `${site.url}${getCanonicalPath(page.path)}`, + ...(page.data.lastModified ? { lastModified: page.data.lastModified } : {}), + })); } diff --git a/components/git-changelog.css b/components/git-changelog.css deleted file mode 100644 index e76349f..0000000 --- a/components/git-changelog.css +++ /dev/null @@ -1,87 +0,0 @@ -/* Nolebase 2.17.1 component styles and UnoCSS utilities, scoped to this React port. - * See git-history-view.tsx for the upstream MIT licence and original-site patch. - */ -.git-changelog { - --history-bg: #8e96aa24; - --history-code-bg: #8e96aa24; - color: var(--vp-c-text-1); - font-size: 16px; - line-height: 24px; -} -.dark .git-changelog { --history-bg: #65758529; --history-code-bg: #65758529; } -.git-changelog h2 { - margin: 48px 0 16px; - border-top: 1px solid var(--vp-c-divider); - padding-top: 24px; - letter-spacing: -.02em; - line-height: 32px; - font-size: 24px; - font-weight: 600; - position: relative; -} -.git-changelog .git-changelog-anchor { - text-decoration: none; - position: absolute; - left: -.87em; - padding-right: .23em; - font-weight: 500; - opacity: 0; - transition: color .25s, opacity .25s; -} -.git-changelog h2:hover .git-changelog-anchor, -.git-changelog-anchor:focus-visible { opacity: 1; } -.git-changelog a { color: var(--vp-c-brand-1); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; transition: color .25s; } -.git-changelog a:hover { color: var(--vp-c-brand-2); } -.git-changelog a:focus-visible, -.git-changelog button:focus-visible { outline: 2px solid var(--vp-c-brand-1); outline-offset: 3px; border-radius: 4px; } -.git-changelog code { - border-radius: 4px; - padding: 3px 6px; - background: var(--history-code-bg); - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; - font-size: .875em; - transition: color .25s, background-color .5s; -} -.git-changelog-empty { font-style: italic; opacity: .7; } -.vp-nolebase-git-changelog-history-container { border-radius: 8px; padding: 16px; background: var(--history-bg); } -.vp-nolebase-git-changelog-history-container[data-fresh] { background: #4ade8029; } -.vp-nolebase-git-changelog-title { position: relative; color: var(--vp-c-text-1); font-size: 14px; user-select: none; transition: color .2s ease-in-out; } -.vp-nolebase-git-changelog-title:hover { color: var(--vp-c-brand-1); } -.git-changelog button { border: 0; padding: 0; color: inherit; background: transparent; font: inherit; line-height: inherit; cursor: pointer; } -.git-changelog-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; text-align: left; } -.vp-nolebase-git-changelog-last-edited-title { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; } -.vp-nolebase-git-changelog-view-full-history-title { display: inline-flex; align-items: center; gap: 12px; padding-left: 36px; font-weight: 400; white-space: nowrap; } -.git-changelog-icon { display: inline-block; flex-shrink: 0; width: 1.2em; min-width: 1.2rem; height: 1.2em; vertical-align: middle; } -.git-changelog .git-changelog-sort { position: absolute; right: calc(7.2em + 28px); top: 0; height: 100%; display: inline-flex; align-items: center; } -.git-changelog-chevron { transition: transform .2s ease-in-out; } -[data-expanded='true'] .git-changelog-chevron { transform: rotate(180deg); } -.git-changelog-collapse { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows .2s ease-in-out, visibility .2s; } -[data-expanded='true'] .git-changelog-collapse { grid-template-rows: 1fr; visibility: visible; } -.git-changelog-collapse-content { min-height: 0; overflow: hidden; } -.git-changelog-list { display: grid; grid-template-columns: 30px minmax(0, 1fr); margin: 12px 0 0 -6px; gap: 6px; } -.git-changelog-list > * { margin-top: auto; margin-bottom: auto; } -.git-changelog-commit-icon { margin: auto; transform: rotate(90deg); opacity: .3; } -.git-changelog-entry { display: flex; align-items: baseline; gap: 4px; min-width: 0; } -.git-changelog-sha { flex-shrink: 0; } -.git-changelog-sha code { color: var(--vp-c-brand-1); font-size: 14px; line-height: 16px; } -.git-changelog-content { min-width: 0; overflow-wrap: anywhere; } -.git-changelog-message { font-size: 14px; line-height: 20px; } -.vp-nolebase-git-changelog-authors { margin: 4px 0 4px 12px; } -.vp-nolebase-git-changelog-author { display: inline; margin-right: .5em; white-space: nowrap; } -.vp-nolebase-git-changelog-author img { display: inline-block; width: 24px; height: 24px; margin: 0; border: 2px solid var(--vp-c-bg-soft); border-radius: 50%; object-fit: cover; vertical-align: middle; } -.vp-nolebase-git-changelog-author-name { margin-left: .25em; font-size: 14px; line-height: 20px; vertical-align: middle; } -.git-changelog-content time, .git-changelog-release time { font-size: 12px; line-height: 16px; opacity: .5; } -.git-changelog-release-icon { display: inline-flex; width: 1.75em; height: 1.75em; margin: auto; border-radius: 50%; background: #9ca3af1a; opacity: .9; } -.git-changelog-release-icon svg { width: 50%; min-width: 50%; height: 50%; margin: auto; } -.git-changelog-release { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; } -.git-changelog-release code { font-weight: 700; } -@media (max-width: 639px) { - .git-changelog-sha, .git-changelog-sha + span { display: none; } - .vp-nolebase-git-changelog-view-full-history-title > span { display: none; } - .git-changelog .git-changelog-sort { right: calc(1.2em + 16px); } - .git-changelog-list { font-size: 12px; } - .git-changelog-message, .vp-nolebase-git-changelog-author-name { font-size: 12px; line-height: 16px; } -} -@media (prefers-reduced-motion: reduce) { - .git-changelog-collapse, .git-changelog-chevron { transition: none; } -} diff --git a/components/git-changelog.tsx b/components/git-changelog.tsx deleted file mode 100644 index 398e516..0000000 --- a/components/git-changelog.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { getPageHistory, shouldShowChangelog, type ChangelogFrontmatter } from '../lib/changelog'; -import { GitHistoryView } from './git-history-view'; - -/** Read history only on the server and preserve all original per-page exclusions. */ -export function GitChangelog({ sourcePath, frontmatter = {} }: { sourcePath: string; frontmatter?: ChangelogFrontmatter }) { - if (!shouldShowChangelog(frontmatter)) return null; - return ; -} diff --git a/components/git-history-view.tsx b/components/git-history-view.tsx deleted file mode 100644 index 8769682..0000000 --- a/components/git-history-view.tsx +++ /dev/null @@ -1,150 +0,0 @@ -'use client'; - -/*! - * Adapted from @nolebase/vitepress-plugin-git-changelog 2.17.1 (MIT). - * https://github.com/nolebase/integrations/tree/v2.17.1/packages/vitepress-plugin-git-changelog - * - * MIT License - * - * Copyright (c) 2023-PRESENT All the contributors of Nólëbase - * Copyright (c) GitHub, Inc. (Octicons) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import { Fragment, useEffect, useId, useState, type ReactNode } from 'react'; -import { differenceInDays, formatDistanceToNow } from 'date-fns'; -import { zhCN } from 'date-fns/locale'; -import type { HistoryAuthor, HistoryCommit } from '../lib/changelog'; -import './git-changelog.css'; - -const repository = 'https://github.com/WHUDAYS/WHUDAYS.github.io'; -const absoluteDate = (date: string) => new Date(date).toLocaleDateString('zh-CN'); -const fullDate = (date: string) => new Date(date).toLocaleString('zh-CN', { dateStyle: 'full', timeStyle: 'long' }); - -// The same Octicons used by Nolebase's UnoCSS build, without its global CSS reset. -const iconPaths = { - "history": "m.427 1.927l1.215 1.215a8.002 8.002 0 1 1-1.6 5.685a.75.75 0 1 1 1.493-.154a6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177M7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.75.75 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4", - "sort-desc": "M0 4.25a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5H.75A.75.75 0 0 1 0 4.25m0 4a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5H.75A.75.75 0 0 1 0 8.25m0 4a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75M13.5 10h2.25a.25.25 0 0 1 .177.427l-3 3a.25.25 0 0 1-.354 0l-3-3A.25.25 0 0 1 9.75 10H12V3.75a.75.75 0 0 1 1.5 0z", - "sort-asc": "m12.927 2.573l3 3A.25.25 0 0 1 15.75 6H13.5v6.75a.75.75 0 0 1-1.5 0V6H9.75a.25.25 0 0 1-.177-.427l3-3a.25.25 0 0 1 .354 0M0 12.25a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75m0-4a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5H.75A.75.75 0 0 1 0 8.25m0-4a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5H.75A.75.75 0 0 1 0 4.25", - "chevron-down": "M12.78 5.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.75.75 0 0 1 1.06 0", - "git-commit": "M11.93 8.5a4.002 4.002 0 0 1-7.86 0H.75a.75.75 0 0 1 0-1.5h3.32a4.002 4.002 0 0 1 7.86 0h3.32a.75.75 0 0 1 0 1.5Zm-1.43-.75a2.5 2.5 0 1 0-5 0a2.5 2.5 0 0 0 5 0", - "rocket": "M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.75 8.75 0 0 1-2.564 6.186l-.458.459q-.472.471-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.75.75 0 0 1-1.11-.418l-.954-3.102a1 1 0 0 1-.145-.125L3.754 9.816a1 1 0 0 1-.124-.145L.528 8.717a.75.75 0 0 1-.418-1.11l1.71-2.774A1.75 1.75 0 0 1 3.31 4h3.204q.433-.508.904-.979l.459-.458A8.75 8.75 0 0 1 14.064 0M8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317l2.143 2.143l2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.25 7.25 0 0 0-5.125 2.123M3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.23.23 0 0 1-.201-.064a.23.23 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12m6.94-3.935q-.132.09-.266.175l-2.35 1.521l.548 1.783l1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116L5.2 5.766q.087-.135.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0a1 1 0 0 1 2 0" -} as const; -function Icon({ name, className = '' }: { name: keyof typeof iconPaths; className?: string }) { - return ; -} - -function safeLink(href: string) { - return /^(?:https?:\/\/|\/|#)/i.test(href) ? href : undefined; -} - -/** Nolebase's inline Markdown and issue links, rendered as escaped React nodes. */ -function CommitMessage({ message }: { message: string }) { - const parts: ReactNode[] = []; - const tokens = /`([^`]+)`|\*\*([^*]+)\*\*|\*([^*]+)\*|\[([^\]]+)\]\(([^)]+)\)|#(\d+)/g; - let cursor = 0; - for (const match of message.matchAll(tokens)) { - parts.push(message.slice(cursor, match.index)); - const [, code, bold, italic, label, href, issue] = match; - parts.push({code !== undefined ? {code} - : bold !== undefined ? {bold} - : italic !== undefined ? {italic} - : issue !== undefined ? #{issue} - : {label}}); - cursor = match.index + match[0].length; - } - parts.push(message.slice(cursor)); - return <>{parts}; -} - -function Author({ author }: { author: HistoryAuthor }) { - const content = <>{`${author.name}{author.name}; - return author.url - ? {content} - : {content}; -} - -function CommittedOn({ commit }: { commit: HistoryCommit }) { - return ; -} - -function CommitList({ commits }: { commits: HistoryCommit[] }) { - return
{commits.map(commit => - {commit.tags?.length ? <> - -
- {commit.tags.map(tag => {tag.name})} - -
- : <> - -
- {commit.shortSha} - - - - {commit.authors.map((author, index) => )} - - -
- } -
)}
; -} - -/** React port of Nolebase 2.17.1 Changelog/CommitRegularLine/CommitTagLine. - * The original site's author-name patch is preserved. Contributors were disabled. - * All records stay in the exported HTML; collapsing only changes their visibility. - */ -export function GitHistoryView({ commits }: { commits: HistoryCommit[] }) { - const [descending, setDescending] = useState(true); - const [expanded, setExpanded] = useState(false); - const [now, setNow] = useState(null); - const historyId = useId(); - useEffect(() => { - setNow(Date.now()); - const timer = window.setInterval(() => setNow(Date.now()), 60_000); - return () => window.clearInterval(timer); - }, []); - const latest = commits[0]; - const fresh = latest && now !== null && differenceInDays(now, new Date(latest.date)) < 1; - const ordered = descending ? commits : [...commits].reverse(); - return
-

页面历史#

- {!latest ?
暂无最近变更历史
:
-
- - -
-
-
-
-
} -
; -} diff --git a/components/mdx.tsx b/components/mdx.tsx index 4903c70..e6bd990 100644 --- a/components/mdx.tsx +++ b/components/mdx.tsx @@ -1,9 +1,8 @@ import defaultMdxComponents from '@fumadocs/base-ui/mdx'; -import { Callout } from '@fumadocs/base-ui/components/callout'; import type { MDXComponents } from 'mdx/types'; import * as content from './content'; export function getMDXComponents(components?: MDXComponents): MDXComponents { - return { ...defaultMdxComponents, ...content, Callout, img: (props) => , ...components }; + return { ...defaultMdxComponents, ...content, img: (props) => , ...components }; } export const useMDXComponents = getMDXComponents; diff --git a/components/page-view-options.tsx b/components/page-view-options.tsx deleted file mode 100644 index d5b7a54..0000000 --- a/components/page-view-options.tsx +++ /dev/null @@ -1,66 +0,0 @@ -'use client'; - -import { ChevronDown, ExternalLink, TextIcon } from 'lucide-react'; -import { Popover, PopoverContent, PopoverTrigger } from '@fumadocs/base-ui/components/ui/popover'; -import { buttonVariants } from '@fumadocs/base-ui/components/ui/button'; - -/* - * Brand icon paths from @fumadocs/base-ui. - * MIT License - * - * Copyright (c) 2023 Fuma - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -const brandPaths = { - "GitHub": "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12", - "OpenAI": "M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z", - "Anthropic": "M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z" -} as const; - -function BrandIcon({ brand }: { brand: keyof typeof brandPaths }) { - return ; -} - -export function PageViewOptions({ markdownUrl, githubUrl, pageUrl }: { - markdownUrl: string; - githubUrl: string; - pageUrl: string; -}) { - const prompt = `请阅读 ${pageUrl},我想询问有关页面内容的问题。`; - const items = [ - { title: '在 GitHub 查看', href: githubUrl, icon: }, - { title: '查看 Markdown', href: markdownUrl, icon: