mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-25 12:38:57 +02:00
fix: use heading itself as anchor for better crawling (#5481)
This commit is contained in:
parent
fd3c0c6619
commit
812327155b
3 changed files with 7 additions and 17 deletions
|
@ -44,16 +44,13 @@ const createAnchorHeading = (
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tag {...props}>
|
<Tag
|
||||||
<a
|
{...props}
|
||||||
aria-hidden="true"
|
className={clsx('anchor', `anchor__${Tag}`, {
|
||||||
tabIndex={-1}
|
[styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
|
||||||
className={clsx('anchor', `anchor__${Tag}`, {
|
[styles.anchorWithStickyNavbar]: !hideOnScroll,
|
||||||
[styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
|
})}
|
||||||
[styles.anchorWithStickyNavbar]: !hideOnScroll,
|
id={id}>
|
||||||
})}
|
|
||||||
id={id}
|
|
||||||
/>
|
|
||||||
{props.children}
|
{props.children}
|
||||||
<a
|
<a
|
||||||
className="hash-link"
|
className="hash-link"
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.anchor {
|
|
||||||
display: block;
|
|
||||||
position: relative;
|
|
||||||
top: -0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hash-link {
|
.hash-link {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
padding-left: 0.5rem;
|
padding-left: 0.5rem;
|
||||||
|
|
|
@ -12,7 +12,6 @@ See https://twitter.com/JoshWComeau/status/1332015868725891076
|
||||||
*/
|
*/
|
||||||
.anchorWithStickyNavbar {
|
.anchorWithStickyNavbar {
|
||||||
scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem);
|
scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem);
|
||||||
/* top: calc(var(--ifm-navbar-height) * -1 - 0.5rem); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.anchorWithHideOnScrollNavbar {
|
.anchorWithHideOnScrollNavbar {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue