UNPKG

@docusaurus/core

Version:

Easy to Maintain Open Source Documentation Websites

40 lines (39 loc) 1.31 kB
/** * 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. */ function getBuildMetaTags(helmet) { // @ts-expect-error: see https://github.com/staylor/react-helmet-async/pull/167 const metaElements = helmet.meta.toComponent() ?? []; return metaElements.map((el) => el.props); } function isNoIndexTag(tag) { if (!tag.name || !tag.content) { return false; } return ( // meta name is not case-sensitive tag.name.toLowerCase() === 'robots' && // Robots directives are not case-sensitive tag.content.toLowerCase().includes('noindex')); } export function toPageCollectedMetadataInternal({ helmet, }) { const tags = getBuildMetaTags(helmet); const noIndex = tags.some(isNoIndexTag); return { helmet, // TODO Docusaurus v4 remove public: { noIndex, }, internal: { htmlAttributes: helmet.htmlAttributes.toString(), bodyAttributes: helmet.bodyAttributes.toString(), title: helmet.title.toString(), meta: helmet.meta.toString(), link: helmet.link.toString(), script: helmet.script.toString(), }, }; }