From 7223a550535bccf15c6daab64d2c7fd96f2e3ea2 Mon Sep 17 00:00:00 2001 From: yuluo-yx Date: Mon, 2 Mar 2026 22:24:53 +0800 Subject: [PATCH] feat: add edit page adn question sidecat Signed-off-by: yuluo-yx --- i18n/en/code.json | 4 ++ i18n/zh-Hans/code.json | 4 ++ project.config.ts | 24 ++++++-- src/theme/TOC/index.tsx | 10 ++++ src/theme/TOCItems/index.tsx | 86 ++++++++++++++++++++++++++++ src/theme/TOCItems/styles.module.css | 31 ++++++++++ 6 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 src/theme/TOC/index.tsx create mode 100644 src/theme/TOCItems/index.tsx create mode 100644 src/theme/TOCItems/styles.module.css diff --git a/i18n/en/code.json b/i18n/en/code.json index dbb91c7c..833bf100 100644 --- a/i18n/en/code.json +++ b/i18n/en/code.json @@ -1048,5 +1048,9 @@ "team.termStart": { "message": "Term Start", "description": "Term start label" + }, + "theme.common.reportAnIssue": { + "message": "Report an issue", + "description": "The link label to report an issue for the current page" } } diff --git a/i18n/zh-Hans/code.json b/i18n/zh-Hans/code.json index 40147e79..db49f634 100644 --- a/i18n/zh-Hans/code.json +++ b/i18n/zh-Hans/code.json @@ -1164,5 +1164,9 @@ "contributing.codeOfConductTitle": { "message": "行为准则", "description": "Code of conduct title" + }, + "theme.common.reportAnIssue": { + "message": "问题反馈", + "description": "The link label to report an issue for the current page" } } diff --git a/project.config.ts b/project.config.ts index afbdc55b..9222702d 100644 --- a/project.config.ts +++ b/project.config.ts @@ -11,12 +11,18 @@ export interface ProjectConfig { website?: string } - // GitHub repository information + // GitHub repository information (project code repo) github: { username: string repoName: string } + // Docs/website repository information + docsGithub: { + username: string + repoName: string + } + // Website deployment information deployment: { url: string @@ -56,12 +62,18 @@ const projectConfig: ProjectConfig = { website: 'https://java2ai.com', // optional }, - // GitHub repository information + // GitHub repository information (project code repo) github: { username: 'alibaba', repoName: 'spring-ai-alibaba', }, + // Docs/website repository information + docsGithub: { + username: 'spring-ai-alibaba', + repoName: 'website', + }, + // Website deployment configuration deployment: { url: 'https://spring-ai-alibaba.github.io', @@ -96,14 +108,18 @@ export const getGitHubUrls = (config: ProjectConfig) => { const { username, repoName } = config.github const baseUrl = `https://github.com/${username}/${repoName}` + const { username: docsUsername, repoName: docsRepoName } = config.docsGithub + const docsBaseUrl = `https://github.com/${docsUsername}/${docsRepoName}` + return { repo: baseUrl, discussions: `${baseUrl}/discussions`, issues: `${baseUrl}/issues`, license: `${baseUrl}/blob/main/LICENSE`, contributing: `${baseUrl}/blob/main/CONTRIBUTING.md`, - editDocs: `${baseUrl}/tree/main/docs/`, - editBlog: `${baseUrl}/tree/main/blog/`, + editDocs: `${docsBaseUrl}/tree/main/`, + editBlog: `${docsBaseUrl}/tree/main/blog/`, + docsRepo: docsBaseUrl, } } diff --git a/src/theme/TOC/index.tsx b/src/theme/TOC/index.tsx new file mode 100644 index 00000000..04f6557d --- /dev/null +++ b/src/theme/TOC/index.tsx @@ -0,0 +1,10 @@ +import React, { type ReactNode } from 'react' +import TOCOriginal from '@theme-original/TOC' +import type TOCType from '@theme/TOC' +import type { WrapperProps } from '@docusaurus/types' + +type Props = WrapperProps + +export default function TOCWrapper(props: Props): ReactNode { + return +} diff --git a/src/theme/TOCItems/index.tsx b/src/theme/TOCItems/index.tsx new file mode 100644 index 00000000..9431a466 --- /dev/null +++ b/src/theme/TOCItems/index.tsx @@ -0,0 +1,86 @@ +import React, { type ReactNode } from 'react' +import TOCItemsOriginal from '@theme-original/TOCItems' +import type TOCItemsType from '@theme/TOCItems' +import type { WrapperProps } from '@docusaurus/types' +import { useDoc } from '@docusaurus/plugin-content-docs/client' +import Translate from '@docusaurus/Translate' +import styles from './styles.module.css' + +type Props = WrapperProps + +function DocPageLinks(): ReactNode { + const { metadata } = useDoc() + const { editUrl } = metadata + const issuesUrl = 'https://github.com/alibaba/spring-ai-alibaba/issues/new' + + return ( + + ) +} + +class DocPageLinksErrorBoundary extends React.Component< + { children: ReactNode }, + { hasError: boolean } +> { + constructor(props: { children: ReactNode }) { + super(props) + this.state = { hasError: false } + } + + static getDerivedStateFromError() { + return { hasError: true } + } + + render() { + if (this.state.hasError) { + return null + } + return this.props.children + } +} + +export default function TOCItemsWrapper(props: Props): ReactNode { + return ( + <> + + + + + + ) +} diff --git a/src/theme/TOCItems/styles.module.css b/src/theme/TOCItems/styles.module.css new file mode 100644 index 00000000..8c12e572 --- /dev/null +++ b/src/theme/TOCItems/styles.module.css @@ -0,0 +1,31 @@ +.docPageLinks { + display: flex; + flex-direction: column; + gap: 8px; + margin-top: 20px; + padding-top: 16px; + border-top: 1px solid var(--ifm-color-emphasis-300); + font-size: 0.8rem; +} + +.link { + display: flex; + align-items: center; + gap: 6px; + color: var(--ifm-color-emphasis-700); + text-decoration: none; + transition: color var(--ifm-transition-fast); + line-height: 1.4; +} + +.link:hover { + color: var(--ifm-color-primary); + text-decoration: none; +} + +.icon { + width: 14px; + height: 14px; + flex-shrink: 0; + fill: currentColor; +}