mirror of
https://gitea.com/gitea/docs.git
synced 2026-03-27 14:11:03 +07:00
Use mdxa to point to versioned links (#27)
Close #17 mdxa is another component that is safe to eject  And right now some links are using `master` as the branch(link will be redirect to `main`), so checked for that as well. Update: Change `master` to `main` in upstream, so also removed check for `master` https://github.com/go-gitea/gitea/pull/25126 # After For example:     Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/27 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: HesterG <hesterg@noreply.gitea.com> Co-committed-by: HesterG <hesterg@noreply.gitea.com>
This commit is contained in:
14
src/theme/MDXComponents/A.js
Normal file
14
src/theme/MDXComponents/A.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import Link from '@docusaurus/Link';
|
||||
import {useDoc} from '@docusaurus/theme-common/internal';
|
||||
|
||||
export default function MDXA(props) {
|
||||
// {assets, contentTitle, frontMatter, metadata, toc}
|
||||
const {metadata} = useDoc();
|
||||
let newProps = {...props};
|
||||
if (metadata.version !== 'current' && (props.href.startsWith('https://github.com/go-gitea/gitea/blob/main'))) {
|
||||
const versionedHref = props.href.replace('main', `release/v${metadata.version}`);
|
||||
newProps = {...props, href: versionedHref};
|
||||
}
|
||||
return <Link {...newProps} />;
|
||||
}
|
||||
Reference in New Issue
Block a user