Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(theme): add __ prefix to technical anchors, search crawlers (Algolia) should ignore them #8909

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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.

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;
}