docs: 🐛 css enhancement + add gtag
Signed-off-by: slumbering <slumbering.pierrot@gmail.com>
This commit is contained in:
52
website/src/theme/Heading/index.js
Normal file
52
website/src/theme/Heading/index.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* eslint-disable jsx-a11y/anchor-has-content, jsx-a11y/anchor-is-valid */
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import {translate} from '@docusaurus/Translate';
|
||||
import {useThemeConfig} from '@docusaurus/theme-common';
|
||||
import './styles.css';
|
||||
import styles from './styles.module.css';
|
||||
import AnchorIcon from "./anchor.svg"
|
||||
|
||||
const Heading = (Tag) =>
|
||||
function TargetComponent({id, ...props}) {
|
||||
const {
|
||||
navbar: {hideOnScroll},
|
||||
} = useThemeConfig();
|
||||
|
||||
if (!id) {
|
||||
return <Tag {...props} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Tag {...props}>
|
||||
<a
|
||||
aria-hidden="true"
|
||||
tabIndex={-1}
|
||||
className={clsx('anchor', {
|
||||
[styles.enhancedAnchor]: !hideOnScroll,
|
||||
})}
|
||||
id={id}
|
||||
/>
|
||||
{props.children}
|
||||
<a
|
||||
className="hash-link"
|
||||
href={`#${id}`}
|
||||
title={translate({
|
||||
id: 'theme.common.headingLinkTitle',
|
||||
message: 'Direct link to heading',
|
||||
description: 'Title for link to heading',
|
||||
})}>
|
||||
<AnchorIcon />
|
||||
</a>
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
|
||||
export default Heading;
|
Reference in New Issue
Block a user