diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e6f6521bbf..cd5260e141 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,6 +12,8 @@ # 1Secure team /docs/1secure/ @netwrix/1secure-docs /sidebars/1secure.js @netwrix/1secure-docs +/docs/1securebeta/ @netwrix/1secure-docs +/sidebars/1securebeta.js @netwrix/1secure-docs /static/files/1secure/ @netwrix/1secure-docs /static/images/1secure/ @netwrix/1secure-docs diff --git a/docs/1securebeta/index.md b/docs/1securebeta/index.md new file mode 100644 index 0000000000..aeba2bcef0 --- /dev/null +++ b/docs/1securebeta/index.md @@ -0,0 +1,11 @@ +--- +title: "Netwrix 1Secure Beta Documentation" +description: "Pre-release documentation for Netwrix 1Secure Beta." +sidebar_position: 1 +--- + +# Netwrix 1Secure Beta Documentation + +This section holds pre-release documentation for Netwrix 1Secure Beta. It isn't listed in the site navigation or search results. + +{/* TODO: replace this placeholder with the beta overview */} diff --git a/sidebars/1securebeta.js b/sidebars/1securebeta.js new file mode 100644 index 0000000000..f4e8941a40 --- /dev/null +++ b/sidebars/1securebeta.js @@ -0,0 +1,8 @@ +module.exports = { + sidebar: [ + { + type: 'autogenerated', + dirName: '.', + }, + ], +}; diff --git a/src/config/products.js b/src/config/products.js index 1aa41af2a5..d19c09005a 100644 --- a/src/config/products.js +++ b/src/config/products.js @@ -32,6 +32,8 @@ * @property {string[]} [categories] - Product categories (can belong to multiple) * @property {string} [icon] - Icon for the product * @property {string} [navbarGroup] - Products sharing a navbarGroup are shown as one nested submenu with this label inside their category dropdown + * @property {boolean} [hideFromNavbar] - Leave the product out of the navbar dropdowns and the landing page. Its pages stay reachable by URL. + * @property {boolean} [noIndex] - Keep the product out of search engines and site search: its pages carry a noindex tag and are left out of the sitemap, production robots.txt disallows its routes, and it is not offered in the search product filter. Pair with hideFromNavbar for an unlisted product such as a beta. */ /** @@ -55,6 +57,25 @@ export const PRODUCTS = [ }, ], }, + { + id: '1securebeta', + name: '1Secure Beta', + description: 'Pre-release documentation for Netwrix 1Secure', + path: 'docs/1securebeta', + categories: ['Data Security Posture Management (DSPM)'], + icon: '', + hideFromNavbar: true, // Unlisted beta: reachable by URL only + noIndex: true, + versions: [ + { + version: 'current', + label: 'Current', + isLatest: true, + sidebarFile: './sidebars/1securebeta.js', + kb: false, // No Knowledge Base for the beta + }, + ], + }, { id: 'accessanalyzer', name: 'Access Analyzer', @@ -1075,6 +1096,7 @@ export function generateDocusaurusPlugins({ apiSidebars = {} } = {}) { versions: { current: { label: version.label, + ...(product.noIndex && { noIndex: true }), }, }, }; diff --git a/src/plugins/robotsTxt.js b/src/plugins/robotsTxt.js index fd2fb48904..f828ae623d 100644 --- a/src/plugins/robotsTxt.js +++ b/src/plugins/robotsTxt.js @@ -1,14 +1,25 @@ import { writeFileSync } from 'fs'; import { join } from 'path'; import { isIndexableSite } from '../config/indexing.js'; +import { PRODUCTS, generateRouteBasePath } from '../config/products.js'; -export function buildRobotsTxt(siteUrl) { +/** Route prefixes of products flagged noIndex, for example /docs/1securebeta. */ +export function noIndexRoutes(products = PRODUCTS) { + return products + .filter((product) => product.noIndex) + .flatMap((product) => + product.versions.map((version) => `/${version.customRoutePath || generateRouteBasePath(product.path, version.version)}`), + ); +} + +export function buildRobotsTxt(siteUrl, disallowRoutes = []) { if (!isIndexableSite(siteUrl)) { // docs-dev has dropped out of search, so crawling is closed too. The // site's noIndex meta tag stays on as a second layer. return 'User-agent: *\nDisallow: /\n'; } - return `User-agent: *\nAllow: /\n\nSitemap: ${new URL(siteUrl).origin}/sitemap.xml\n`; + const disallow = [...new Set(disallowRoutes)].map((route) => `Disallow: ${route}\n`).join(''); + return `User-agent: *\nAllow: /\n${disallow}\nSitemap: ${new URL(siteUrl).origin}/sitemap.xml\n`; } /** Writes build/robots.txt for the host this build is deployed to. */ @@ -16,7 +27,7 @@ export default function robotsTxtPlugin() { return { name: 'robots-txt', async postBuild({ siteConfig, outDir }) { - writeFileSync(join(outDir, 'robots.txt'), buildRobotsTxt(siteConfig.url)); + writeFileSync(join(outDir, 'robots.txt'), buildRobotsTxt(siteConfig.url, noIndexRoutes())); }, }; } diff --git a/src/plugins/robotsTxt.test.mjs b/src/plugins/robotsTxt.test.mjs index d3e81d89b5..94bf4770c2 100644 --- a/src/plugins/robotsTxt.test.mjs +++ b/src/plugins/robotsTxt.test.mjs @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import { test } from 'node:test'; import { isIndexableSite } from '../config/indexing.js'; -import { buildRobotsTxt } from './robotsTxt.js'; +import { buildRobotsTxt, noIndexRoutes } from './robotsTxt.js'; test('docs.netwrix.com is crawlable and advertises its sitemap', () => { assert.equal( @@ -21,3 +21,16 @@ test('only docs.netwrix.com is indexable', () => { assert.equal(isIndexableSite('https://docs-dev.netwrix.com'), false); assert.equal(isIndexableSite('http://localhost:4500'), false); }); + +test('docs.netwrix.com disallows the routes of noIndex products', () => { + const products = [ + { id: 'listed', path: 'docs/listed', versions: [{ version: 'current' }] }, + { id: 'beta', path: 'docs/beta', noIndex: true, versions: [{ version: 'current' }, { version: '2.0' }] }, + ]; + const routes = noIndexRoutes(products); + assert.deepEqual(routes, ['/docs/beta', '/docs/beta/2_0']); + assert.equal( + buildRobotsTxt('https://docs.netwrix.com', routes), + 'User-agent: *\nAllow: /\nDisallow: /docs/beta\nDisallow: /docs/beta/2_0\n\nSitemap: https://docs.netwrix.com/sitemap.xml\n', + ); +}); diff --git a/src/theme/SearchBar/index.js b/src/theme/SearchBar/index.js index 781155f71f..9884e23df3 100644 --- a/src/theme/SearchBar/index.js +++ b/src/theme/SearchBar/index.js @@ -355,7 +355,7 @@ function useSearchParameters({contextualSearch, productFacetFilters = [], ...pro // Values MUST match Algolia facet values exactly const PRODUCT_OPTIONS = [ {label: 'All products', value: '__all__'}, - ...PRODUCTS.map(product => ({ + ...PRODUCTS.filter(product => !product.noIndex).map(product => ({ label: product.name, value: product.name, })) diff --git a/src/theme/SearchPage/index.js b/src/theme/SearchPage/index.js index a051926f29..af1187116e 100644 --- a/src/theme/SearchPage/index.js +++ b/src/theme/SearchPage/index.js @@ -36,7 +36,7 @@ function stripHtmlTagsToText(input) { // Generate product options from PRODUCTS config const PRODUCT_OPTIONS = [ {label: 'All products', value: '__all__'}, - ...PRODUCTS.map(product => ({ + ...PRODUCTS.filter(product => !product.noIndex).map(product => ({ label: product.name, value: product.name, }))