Skip to content

Commit

Permalink
Rough draft: quick, easy solution for noindexing entire branches from… (
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs authored Oct 8, 2024
1 parent 5c07775 commit bbddf60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/components/DocumentBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export const Head = ({ pageContext, data }) => {
// Retrieves the canonical URL based on certain situations
// i.e. eol'd, non-eol'd, snooty.toml or ..metadata:: directive (highest priority)
const canonical = useCanonicalUrl(meta, metadata, slug, repoBranches);
const noIndexing = repoBranches.branches.find((br) => br.gitBranchName === metadata.branch)?.noIndexing;

// construct Structured Data
const techArticleSd = useMemo(() => {
Expand All @@ -229,6 +230,7 @@ export const Head = ({ pageContext, data }) => {
siteTitle={siteTitle}
showDocsLandingTitle={isDocsLandingHomepage && slug === '/'}
slug={slug}
noIndexing={noIndexing}
/>
{meta.length > 0 && meta.map((c, i) => <Meta key={`meta-${i}`} nodeData={c} />)}
{twitter.length > 0 && twitter.map((c) => <Twitter {...c} />)}
Expand Down
4 changes: 3 additions & 1 deletion src/components/SEO.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useSiteMetadata } from '../hooks/use-site-metadata';
const DEFAULT_TWITTER_SITE = '@mongodb';
const metaUrl = `https://www.mongodb.com/docs/assets/meta_generic.png`;

const SEO = ({ pageTitle, siteTitle, showDocsLandingTitle, canonical, slug }) => {
const SEO = ({ pageTitle, siteTitle, showDocsLandingTitle, canonical, slug, noIndexing }) => {
// Using static siteUrl instead of location.origin due to origin being undefined at build time
const { siteUrl } = useSiteMetadata();
const localeHrefMap = getLocaleMapping(siteUrl, slug);
Expand All @@ -32,6 +32,7 @@ const SEO = ({ pageTitle, siteTitle, showDocsLandingTitle, canonical, slug }) =>
<meta property="twitter:title" content={pageTitle} />
<meta name="twitter:image" content={metaUrl} />
<meta name="twitter:image:alt" content="MongoDB logo featuring a green leaf on a dark green background." />
{noIndexing && <meta name="robots" content="noindex" />}
{canonical && <link data-testid="canonical" id="canonical" rel="canonical" key={canonical} href={canonical} />}
</>
);
Expand All @@ -42,6 +43,7 @@ SEO.propTypes = {
siteTitle: PropTypes.string.isRequired,
showDocsLandingTitle: PropTypes.bool,
canonical: PropTypes.string,
noIndexing: PropTypes.bool,
};

export default SEO;

0 comments on commit bbddf60

Please sign in to comment.