Skip to content

Commit 8bf4721

Browse files
authored
[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.
1 parent bf54660 commit 8bf4721

4 files changed

Lines changed: 14 additions & 75 deletions

File tree

.github/workflows/build-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ on:
2222
pull_request:
2323

2424
concurrency:
25-
group: ${{ github.ref }} (Build Extensions)
26-
cancel-in-progress: false
25+
group: build-check-${{ github.event.pull_request.number || github.ref }}
26+
cancel-in-progress: true
2727

2828
jobs:
2929
build-and-deploy:

src/scss/components/markdown.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@
257257
}
258258
.tabs-container .tabs {
259259
position: relative;
260+
// Isolate the active tab's z-index (999, set above so the active
261+
// tab sits on top of .tabs::before) from the rest of the page so
262+
// it can't climb above the sticky docs search bar.
263+
isolation: isolate;
260264
padding-left: 0 !important;
261265
}
262266
.tabs-container .tabs::before {

src/theme/DocItem/Layout/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ import DocItemContent from '@theme/DocItem/Content';
1515
import DocBreadcrumbs from '@theme/DocBreadcrumbs';
1616
import ContentVisibility from '@theme/ContentVisibility';
1717
import type { Props } from '@theme/DocItem/Layout';
18-
import { generateUrl } from './pathTransfer';
1918
import { DocsEdit } from '../../../components/Icons/docs-edit';
2019

2120
import styles from './styles.module.css';
2221

22+
const GITHUB_TREE_BASE = 'https://github.com/apache/doris-website/tree/master/';
23+
24+
function sourceToEditUrl(source: string | undefined): string {
25+
if (!source) return GITHUB_TREE_BASE;
26+
return `${GITHUB_TREE_BASE}${source.replace(/^@site\//, '')}`;
27+
}
28+
2329
/**
2430
* Decide if the toc should be rendered, on mobile or desktop viewports
2531
*/
@@ -72,7 +78,7 @@ export default function DocItemLayout({ children }: Props): JSX.Element {
7278
{isNew ? (
7379
<></>
7480
) : (
75-
<Link to={generateUrl(location.pathname)} className={`mr-6 ${styles.footerBtn}`}>
81+
<Link to={sourceToEditUrl(metadata.source)} className={`mr-6 ${styles.footerBtn}`}>
7682
<DocsEdit /> <span className="ml-2">{isZH ? '编辑本页' : 'Edit this page'}</span>
7783
</Link>
7884
)}

src/theme/DocItem/Layout/pathTransfer.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)