Skip to content
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions docs/1securebeta/index.md
Original file line number Diff line number Diff line change
@@ -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 */}
8 changes: 8 additions & 0 deletions sidebars/1securebeta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
sidebar: [
{
type: 'autogenerated',
dirName: '.',
},
],
};
22 changes: 22 additions & 0 deletions src/config/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

/**
Expand All @@ -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',
Expand Down Expand Up @@ -1075,6 +1096,7 @@ export function generateDocusaurusPlugins({ apiSidebars = {} } = {}) {
versions: {
current: {
label: version.label,
...(product.noIndex && { noIndex: true }),
},
},
};
Expand Down
17 changes: 14 additions & 3 deletions src/plugins/robotsTxt.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
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. */
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()));
},
};
}
15 changes: 14 additions & 1 deletion src/plugins/robotsTxt.test.mjs
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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',
);
});
2 changes: 1 addition & 1 deletion src/theme/SearchBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}))
Expand Down
2 changes: 1 addition & 1 deletion src/theme/SearchPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}))
Expand Down
Loading