/
githubmirror
/
docusaurus
Обзор
Документация
Войти
/
githubmirror
/
docusaurus
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/docusaurus-theme-common/src/utils/anchorUtils.ts
31 строка
965 B
Sébastien Lorber
fix(theme): Fix CSS `scroll-margin-top` when clicking footnote items, factorize code (#11466)
09 окт 2025, 13:34
Не верифицирован
09 окт 2025, 13:34
ac630f8
Код
Авторство
О чём код?
/** * 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. */ import {useThemeConfig} from './useThemeConfig'; import styles from './anchorUtils.module.css'; /** * When the navbar is sticky, this ensures that when clicking a hash link, * we do not navigate to an anchor that will appear below the navbar. * This happens in particular for MDX headings and footnotes. * * See https://github.com/facebook/docusaurus/issues/11232 * See also headings case https://x.com/JoshWComeau/status/1332015868725891076 */ export function useAnchorTargetClassName( id: string | undefined, ): string | undefined { const { navbar: {hideOnScroll}, } = useThemeConfig(); if (typeof id === 'undefined') { return undefined; } return hideOnScroll ? styles.anchorTargetHideOnScrollNavbar : styles.anchorTargetStickyNavbar; }