Skip to content

Commit

Permalink
fix(theme): add __ prefix to technical anchors, search crawlers (Algo…
Browse files Browse the repository at this point in the history
…lia) should ignore them (#8909)
  • Loading branch information
slorber committed May 15, 2023
1 parent 8346c23 commit b345e9b
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 15 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import {useLocationChange} from './useLocationChange';
* The id of the element that should become focused on a page
* that does not have a <main> html tag.
* Focusing the Docusaurus Layout children is a reasonable fallback.
*
* __ prefix allows search crawlers (Algolia/DocSearch) to ignore anchors
* https://github.com/facebook/docusaurus/issues/8883#issuecomment-1516328368
*/
export const SkipToContentFallbackId = 'docusaurus_skipToContent_fallback';
export const SkipToContentFallbackId = '__docusaurus_skipToContent_fallback';

/**
* Returns the skip to content element to focus when the link is clicked.
Expand Down
5 changes: 4 additions & 1 deletion packages/docusaurus-utils-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/

export const blogPostContainerID = 'post-content';
// __ prefix allows search crawlers (Algolia/DocSearch) to ignore anchors
// https://github.com/facebook/docusaurus/issues/8883#issuecomment-1516328368
export const blogPostContainerID = '__blog-post-container';

export {
default as applyTrailingSlash,
type ApplyTrailingSlashParams,
Expand Down
10 changes: 5 additions & 5 deletions packages/docusaurus/src/client/BaseUrlIssueBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
// Double-security: critical CSS will hide the banner if CSS can load!
import './styles.module.css';

const BannerContainerId = 'docusaurus-base-url-issue-banner-container';

const BannerId = 'docusaurus-base-url-issue-banner';

// __ prefix allows search crawlers (Algolia/DocSearch) to ignore anchors
// https://github.com/facebook/docusaurus/issues/8883#issuecomment-1516328368
const BannerContainerId = '__docusaurus-base-url-issue-banner-container';
const BannerId = '__docusaurus-base-url-issue-banner';
const SuggestionContainerId =
'docusaurus-base-url-issue-banner-suggestion-container';
'__docusaurus-base-url-issue-banner-suggestion-container';

const InsertBannerWindowAttribute = '__DOCUSAURUS_INSERT_BASEURL_BANNER';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

:global(#docusaurus-base-url-issue-banner-container) {
:global(#__docusaurus-base-url-issue-banner-container) {
display: none;
}

0 comments on commit b345e9b

Please sign in to comment.