This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new 8bf472181d8 [fix](docs) use metadata.source so "Edit this page" links
to the real .md/.mdx file (#3648)
8bf472181d8 is described below
commit 8bf472181d8703ae7c83cb557a87eaa3d9a99160
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Thu May 14 15:17:57 2026 -0700
[fix](docs) use metadata.source so "Edit this page" links to the real
.md/.mdx file (#3648)
The previous logic in pathTransfer.ts rebuilt the source path from
location.pathname and unconditionally appended .md, so any .mdx file
(e.g. docs-next/connection-integration/mysql-proto.mdx) produced a
broken GitHub link. Use Docusaurus's metadata.source instead, which
always carries the correct file extension across all locales and
versioned docs.
---
.github/workflows/build-check.yml | 4 +-
src/scss/components/markdown.scss | 4 ++
src/theme/DocItem/Layout/index.tsx | 10 ++++-
src/theme/DocItem/Layout/pathTransfer.ts | 71 --------------------------------
4 files changed, 14 insertions(+), 75 deletions(-)
diff --git a/.github/workflows/build-check.yml
b/.github/workflows/build-check.yml
index cea8da9c74e..69ce129ac5b 100644
--- a/.github/workflows/build-check.yml
+++ b/.github/workflows/build-check.yml
@@ -22,8 +22,8 @@ on:
pull_request:
concurrency:
- group: ${{ github.ref }} (Build Extensions)
- cancel-in-progress: false
+ group: build-check-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: true
jobs:
build-and-deploy:
diff --git a/src/scss/components/markdown.scss
b/src/scss/components/markdown.scss
index 68591fd3594..58efd7fe2a1 100644
--- a/src/scss/components/markdown.scss
+++ b/src/scss/components/markdown.scss
@@ -257,6 +257,10 @@
}
.tabs-container .tabs {
position: relative;
+ // Isolate the active tab's z-index (999, set above so the active
+ // tab sits on top of .tabs::before) from the rest of the page so
+ // it can't climb above the sticky docs search bar.
+ isolation: isolate;
padding-left: 0 !important;
}
.tabs-container .tabs::before {
diff --git a/src/theme/DocItem/Layout/index.tsx
b/src/theme/DocItem/Layout/index.tsx
index 3564af42648..f58dea3d678 100644
--- a/src/theme/DocItem/Layout/index.tsx
+++ b/src/theme/DocItem/Layout/index.tsx
@@ -15,11 +15,17 @@ import DocItemContent from '@theme/DocItem/Content';
import DocBreadcrumbs from '@theme/DocBreadcrumbs';
import ContentVisibility from '@theme/ContentVisibility';
import type { Props } from '@theme/DocItem/Layout';
-import { generateUrl } from './pathTransfer';
import { DocsEdit } from '../../../components/Icons/docs-edit';
import styles from './styles.module.css';
+const GITHUB_TREE_BASE =
'https://github.com/apache/doris-website/tree/master/';
+
+function sourceToEditUrl(source: string | undefined): string {
+ if (!source) return GITHUB_TREE_BASE;
+ return `${GITHUB_TREE_BASE}${source.replace(/^@site\//, '')}`;
+}
+
/**
* Decide if the toc should be rendered, on mobile or desktop viewports
*/
@@ -72,7 +78,7 @@ export default function DocItemLayout({ children }: Props):
JSX.Element {
{isNew ? (
<></>
) : (
- <Link to={generateUrl(location.pathname)}
className={`mr-6 ${styles.footerBtn}`}>
+ <Link to={sourceToEditUrl(metadata.source)}
className={`mr-6 ${styles.footerBtn}`}>
<DocsEdit /> <span className="ml-2">{isZH ?
'编辑本页' : 'Edit this page'}</span>
</Link>
)}
diff --git a/src/theme/DocItem/Layout/pathTransfer.ts
b/src/theme/DocItem/Layout/pathTransfer.ts
deleted file mode 100644
index 277c8fe5355..00000000000
--- a/src/theme/DocItem/Layout/pathTransfer.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-const transformPathWithoutZhCN = (pathname: string): string => {
- if (pathname.startsWith('/docs-next/')) {
- return `/docs-next${pathname.replace('/docs-next/dev', '')}.md`;
- }
- if(pathname.startsWith('/docs')){
- const pathWithoutDocs = pathname.replace('/docs', '');
- if(pathname.includes('/4.x')){
- return
`/versioned_docs/version-4.x${pathWithoutDocs.replace('/4.x', '')}.md`;
- }else if (pathname.includes('/3.x')) {
- return
`/versioned_docs/version-3.x${pathWithoutDocs.replace('/3.x', '')}.md`;
- } else if (pathname.includes('/2.0')) {
- return
`/versioned_docs/version-2.0${pathWithoutDocs.replace('/2.0', '')}.md`;
- } else if (pathname.includes('/1.2')) {
- return
`/versioned_docs/version-1.2${pathWithoutDocs.replace('/1.2', '')}.md`;
- } else if (pathname.includes('/dev')) {
- return `/docs${pathWithoutDocs.replace('/dev', '')}.md`;
- } else {
- return `/versioned_docs/version-2.1${pathWithoutDocs}.md`;
- }
- }else{
- // community
- return `${pathname}.md`
- }
-};
-
-const stripLocalePrefix = (pathname: string): string => {
- const segments = pathname.split('/').filter(Boolean);
- if (segments.length === 0) {
- return pathname;
- }
- if (/^[a-z]{2}(?:-[A-Z]{2})?$/.test(segments[0])) {
- return `/${segments.slice(1).join('/')}`;
- }
- return pathname;
-};
-
-const transformPathWithZhCN = (pathname: string): string => {
- if (pathname.startsWith('/zh-CN/docs-next/')) {
- return
`/i18n/zh-CN/docusaurus-plugin-content-docs-next/current${pathname.replace('/zh-CN/docs-next/dev',
'')}.md`;
- }
- if (pathname.startsWith('/zh-CN/docs')) {
- if(pathname.includes('/4.x')){
- return
`/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x${pathname.replace('/zh-CN/docs/4.x',
'')}.md`;
- }else if (pathname.includes('/3.x')) {
- return
`/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x${pathname.replace('/zh-CN/docs/3.x',
'')}.md`;
- } else if (pathname.includes('/2.0')) {
- return
`/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0${pathname.replace('/zh-CN/docs/2.0',
'')}.md`;
- } else if (pathname.includes('/1.2')) {
- return
`/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2${pathname.replace('/zh-CN/docs/1.2',
'')}.md`;
- } else if (pathname.includes('/dev')) {
- return
`/i18n/zh-CN/docusaurus-plugin-content-docs/current${pathname.replace('/zh-CN/docs/dev',
'')}.md`;
- } else {
- return
`/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1${pathname.replace('/zh-CN/docs',
'')}.md`;;
- }
- } else {
- // community
- return
`/i18n/zh-CN/docusaurus-plugin-content-docs-community/current${pathname.replace('/zh-CN/community','')}.md`
- }
-}
-const transformDocPath = (pathname: string): string => {
- if (pathname.startsWith('/zh-CN')) {
- return transformPathWithZhCN(pathname)
- } else {
- return transformPathWithoutZhCN(stripLocalePrefix(pathname));
- }
-};
-
-export const generateUrl = (pathname: string): string => {
- const transformedPath = transformDocPath(pathname);
- return
`https://github.com/apache/doris-website/tree/master${transformedPath}`;
-};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]