From 294ecd6230dc9b00f84e352ebdc67852d831e9ad Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Tue, 3 Nov 2026 16:20:45 +0000 Subject: [PATCH 1/4] Hide release notes templates in snapshot versions --- CONTRIBUTING.md | 1 + .../community-edition/community.mdx | 1 + .../enterprise-edition/enterprise.mdx | 1 + hazelcast/install-and-upgrade/releases.mdx | 1 + .../install-and-upgrade/release-notes.mdx | 1 + operator/get-started/release-notes.mdx | 1 + src/docsPlugins.ts | 23 ++++++++++++------- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db7b269e..3314adc5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,6 +9,7 @@ Each documentation page is built from an MDX file. Each file starts with YAML fr - `sidebar_label`: the label that's shown in the side navigation. - `sidebar_position`: the position of this page within its section in the side navigation. - `slug`: used to maintain URLs from the previous documentation platform. Don't add a slug for new pages, or edit existing slugs. +- `hide_in_snapshot: true`: removes the page from the side navigation of the unreleased snapshot version. The page stays reachable by its URL, and the key has no effect in releases. - `enterprise: true`, `beta: true`, or `experimental: true`: shows a badge at the top of the page. The `enterprise` and `beta` badges also show next to the page in the side navigation. Pages in `cloud/` and `tutorials/` can also have `cloud_title`, `cloud_tags`, and `cloud_order` keys. The Hazelcast Cloud console reads them. Do not remove or rename them. diff --git a/hazelcast/install-and-upgrade/community-edition/community.mdx b/hazelcast/install-and-upgrade/community-edition/community.mdx index a16e49d9..b0c63620 100644 --- a/hazelcast/install-and-upgrade/community-edition/community.mdx +++ b/hazelcast/install-and-upgrade/community-edition/community.mdx @@ -3,6 +3,7 @@ title: "Community Edition Release Notes" sidebar_label: "Release Notes" sidebar_position: 1 slug: /release-notes/community +hide_in_snapshot: true --- :::important diff --git a/hazelcast/install-and-upgrade/enterprise-edition/enterprise.mdx b/hazelcast/install-and-upgrade/enterprise-edition/enterprise.mdx index c7ad974f..d8ff94a4 100644 --- a/hazelcast/install-and-upgrade/enterprise-edition/enterprise.mdx +++ b/hazelcast/install-and-upgrade/enterprise-edition/enterprise.mdx @@ -4,6 +4,7 @@ sidebar_label: "Release Notes" sidebar_position: 1 slug: /release-notes/enterprise enterprise: true +hide_in_snapshot: true --- :::important diff --git a/hazelcast/install-and-upgrade/releases.mdx b/hazelcast/install-and-upgrade/releases.mdx index 22abb60f..50cbf602 100644 --- a/hazelcast/install-and-upgrade/releases.mdx +++ b/hazelcast/install-and-upgrade/releases.mdx @@ -3,6 +3,7 @@ title: "Hazelcast Platform release notes" sidebar_label: "Release Notes" sidebar_position: 2 slug: /release-notes/releases +hide_in_snapshot: true --- :::important diff --git a/management-center/install-and-upgrade/release-notes.mdx b/management-center/install-and-upgrade/release-notes.mdx index 37f5909b..c02c579b 100644 --- a/management-center/install-and-upgrade/release-notes.mdx +++ b/management-center/install-and-upgrade/release-notes.mdx @@ -2,6 +2,7 @@ title: "Release Notes" sidebar_position: 3 slug: /release-notes/release-notes +hide_in_snapshot: true --- These release notes list any new features, enhancements, fixes, security issues and breaking changes that were made for Hazelcast Management Center. diff --git a/operator/get-started/release-notes.mdx b/operator/get-started/release-notes.mdx index 88f52b16..e6418687 100644 --- a/operator/get-started/release-notes.mdx +++ b/operator/get-started/release-notes.mdx @@ -2,6 +2,7 @@ title: "Release notes" sidebar_position: 3 slug: /release-notes +hide_in_snapshot: true --- These release notes list any new features, enhancements, fixes, and breaking changes implemented between version 5.19.0 and version 5.20.0 of Hazelcast Platform Operator. diff --git a/src/docsPlugins.ts b/src/docsPlugins.ts index 9f142151..444dc906 100644 --- a/src/docsPlugins.ts +++ b/src/docsPlugins.ts @@ -62,18 +62,25 @@ type GeneratorArgs = Parameters>[0 type SidebarItems = Awaited>; // Wraps the default generator to tag each doc link, and each category whose landing page is a doc, with its badge class. -const sidebarItemsGenerator: NonNullable = async ({ +// A doc with `hide_in_snapshot: true` is also dropped from the sidebar of the component's unreleased snapshot (main while no release matches it). +// The page stays reachable by URL, so links to it do not break. +const sidebarItemsGenerator = (id: string): NonNullable => async ({ defaultSidebarItemsGenerator, ...args }) => { const frontMatterById = new Map(args.docs.map((doc) => [doc.id, doc.frontMatter as {[key: string]: unknown}])); + const inSnapshot = args.version.versionName === 'current' && id in snapshotSegs; + const hidden = (docId: string | undefined) => + inSnapshot && docId !== undefined && frontMatterById.get(docId)?.hide_in_snapshot === true; const tag = (items: SidebarItems): SidebarItems => - items.map((item) => { - const docId = item.type === 'doc' ? item.id : item.type === 'category' && item.link?.type === 'doc' ? item.link.id : undefined; - const badge = docId === undefined ? undefined : navBadgeClass(frontMatterById.get(docId)); - const tagged = badge ? {...item, className: [item.className, badge].filter(Boolean).join(' ')} : item; - return tagged.type === 'category' ? {...tagged, items: tag(tagged.items)} : tagged; - }); + items + .filter((item) => !(item.type === 'doc' && hidden(item.id))) + .map((item) => { + const docId = item.type === 'doc' ? item.id : item.type === 'category' && item.link?.type === 'doc' ? item.link.id : undefined; + const badge = docId === undefined ? undefined : navBadgeClass(frontMatterById.get(docId)); + const tagged = badge ? {...item, className: [item.className, badge].filter(Boolean).join(' ')} : item; + return tagged.type === 'category' ? {...tagged, items: tag(tagged.items)} : tagged; + }); return tag(await defaultSidebarItemsGenerator({...args})); }; @@ -86,7 +93,7 @@ function contentDocs(options: Options): PluginConfig { ...options, // Docusaurus appends each page's repo-relative path, so versioned pages link to their own copy under _versioned_docs. editUrl: 'https://github.com/hazelcast/documentation/edit/main/', - sidebarItemsGenerator, + sidebarItemsGenerator: sidebarItemsGenerator(options.id ?? 'default'), beforeDefaultRemarkPlugins: [ ...(options.beforeDefaultRemarkPlugins ?? []), [headingVariables, {pluginId: options.id}], From 28f5236301449c839a9750a41766c0b2fa05f52f Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Tue, 3 Nov 2026 16:30:40 +0000 Subject: [PATCH 2/4] Fix tests --- src/test/docsPlugins.test.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/test/docsPlugins.test.js b/src/test/docsPlugins.test.js index 776f0384..45ed05bb 100644 --- a/src/test/docsPlugins.test.js +++ b/src/test/docsPlugins.test.js @@ -83,9 +83,9 @@ function styledBadgeClasses () { return new Set([...css.matchAll(/\.(nav-badge-[a-z]+) > \.menu__link::after/g)].map((m) => m[1])) } -async function sidebar (frontMatterById, items) { +async function sidebar (frontMatterById, items, versionName = '5.7') { const docs = Object.entries(frontMatterById).map(([id, frontMatter]) => ({id, frontMatter})) - return configs.hazelcast.sidebarItemsGenerator({defaultSidebarItemsGenerator: async () => items, docs}) + return configs.hazelcast.sidebarItemsGenerator({defaultSidebarItemsGenerator: async () => items, docs, version: {versionName}}) } test('a beta or enterprise page gets the matching sidebar badge class, and the CSS styles it', async () => { @@ -120,6 +120,13 @@ test('a category takes the badge of its landing page, nested items are tagged, a assert.equal(noLanding.items[0].className, 'nav-badge-beta') }) +test('hide_in_snapshot drops a page from the snapshot sidebar only', async () => { + const items = [{type: 'doc', id: 'a'}, {type: 'doc', id: 'b'}] + const frontMatter = {a: {hide_in_snapshot: true}, b: {}} + assert.deepEqual((await sidebar(frontMatter, items, 'current')).map((i) => i.id), ['b']) + assert.deepEqual((await sidebar(frontMatter, items, '5.7')).map((i) => i.id), ['a', 'b']) +}) + // Version names are dotted numbers, compared numerically: 5.10 is newer than 5.9. const compareVersions = (a, b) => { const pa = a.split('.').map(Number) From ff9da33387b7935fa64ecfc8d15fb521e2452780 Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Tue, 3 Nov 2026 16:42:19 +0000 Subject: [PATCH 3/4] Use unlisted flag --- CONTRIBUTING.md | 2 +- docusaurus.config.ts | 3 ++- src/docsPlugins.ts | 36 ++++++++++++++++++++---------------- src/test/docsPlugins.test.js | 22 +++++++++++++++------- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3314adc5..ee4efae2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ Each documentation page is built from an MDX file. Each file starts with YAML fr - `sidebar_label`: the label that's shown in the side navigation. - `sidebar_position`: the position of this page within its section in the side navigation. - `slug`: used to maintain URLs from the previous documentation platform. Don't add a slug for new pages, or edit existing slugs. -- `hide_in_snapshot: true`: removes the page from the side navigation of the unreleased snapshot version. The page stays reachable by its URL, and the key has no effect in releases. +- `hide_in_snapshot: true`: makes the page [unlisted](https://docusaurus.io/docs/create-doc#unlisted) in the unreleased snapshot version. An unlisted page is hidden from the side navigation, search engines, and the sitemap, and it stays reachable by its URL. The key has no effect in releases, and it has no effect on the dev server. - `enterprise: true`, `beta: true`, or `experimental: true`: shows a badge at the top of the page. The `enterprise` and `beta` badges also show next to the page in the side navigation. Pages in `cloud/` and `tutorials/` can also have `cloud_title`, `cloud_tags`, and `cloud_order` keys. The Hazelcast Cloud console reads them. Do not remove or rename them. diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 7389b93f..8894d9f7 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -2,7 +2,7 @@ import {themes as prismThemes} from 'prism-react-renderer'; import type {Config} from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; import {redirects} from './src/redirects'; -import {docs, versionedDocs, versionedInstances, latestSegs, canonicalSitemapItems} from './src/docsPlugins'; +import {docs, versionedDocs, versionedInstances, latestSegs, canonicalSitemapItems, parseFrontMatter} from './src/docsPlugins'; import {variables, versionedVariables} from './src/variables'; // Retired versions served as static Antora HTML from a separate site. See plugins/archived-versions. @@ -48,6 +48,7 @@ const config: Config = { onBrokenAnchors: 'warn', markdown: { + parseFrontMatter, hooks: { onBrokenMarkdownLinks: 'throw', onBrokenMarkdownImages: 'throw', diff --git a/src/docsPlugins.ts b/src/docsPlugins.ts index 444dc906..1bf4ba47 100644 --- a/src/docsPlugins.ts +++ b/src/docsPlugins.ts @@ -6,7 +6,7 @@ // _versioned_sidebars/ sidebar stubs, gitignored (see ensureVersionedSidebars) import fs from 'fs'; import path from 'path'; -import type {PluginConfig} from '@docusaurus/types'; +import type {ParseFrontMatter, PluginConfig} from '@docusaurus/types'; import type {Options} from '@docusaurus/plugin-content-docs'; import latestLinks, {type LatestSegs} from './remark/latestLinks'; import headingVariables from './remark/headingVariables'; @@ -48,6 +48,17 @@ export function canonicalSitemapItems(items: T[]): T[] }); } +// `markdown.parseFrontMatter` hook: a page with `hide_in_snapshot: true` in a component's unreleased snapshot becomes `unlisted`. +// The release script copies frontmatter into each release, so writing `unlisted` in the file would hide the page in releases too. +export const parseFrontMatter: ParseFrontMatter = async (params) => { + const result = await params.defaultParseFrontMatter(params); + const [id] = path.relative(siteDir, params.filePath).split(path.sep); + if (result.frontMatter.hide_in_snapshot === true && id !== undefined && id in snapshotSegs) { + result.frontMatter.unlisted = true; + } + return result; +}; + // `caution`/`important` are not default Docusaurus admonition keywords; fidelity Layer 2 compares admonition types. const admonitions = {keywords: ['caution', 'important'], extendDefaults: true}; @@ -62,25 +73,18 @@ type GeneratorArgs = Parameters>[0 type SidebarItems = Awaited>; // Wraps the default generator to tag each doc link, and each category whose landing page is a doc, with its badge class. -// A doc with `hide_in_snapshot: true` is also dropped from the sidebar of the component's unreleased snapshot (main while no release matches it). -// The page stays reachable by URL, so links to it do not break. -const sidebarItemsGenerator = (id: string): NonNullable => async ({ +const sidebarItemsGenerator: NonNullable = async ({ defaultSidebarItemsGenerator, ...args }) => { const frontMatterById = new Map(args.docs.map((doc) => [doc.id, doc.frontMatter as {[key: string]: unknown}])); - const inSnapshot = args.version.versionName === 'current' && id in snapshotSegs; - const hidden = (docId: string | undefined) => - inSnapshot && docId !== undefined && frontMatterById.get(docId)?.hide_in_snapshot === true; const tag = (items: SidebarItems): SidebarItems => - items - .filter((item) => !(item.type === 'doc' && hidden(item.id))) - .map((item) => { - const docId = item.type === 'doc' ? item.id : item.type === 'category' && item.link?.type === 'doc' ? item.link.id : undefined; - const badge = docId === undefined ? undefined : navBadgeClass(frontMatterById.get(docId)); - const tagged = badge ? {...item, className: [item.className, badge].filter(Boolean).join(' ')} : item; - return tagged.type === 'category' ? {...tagged, items: tag(tagged.items)} : tagged; - }); + items.map((item) => { + const docId = item.type === 'doc' ? item.id : item.type === 'category' && item.link?.type === 'doc' ? item.link.id : undefined; + const badge = docId === undefined ? undefined : navBadgeClass(frontMatterById.get(docId)); + const tagged = badge ? {...item, className: [item.className, badge].filter(Boolean).join(' ')} : item; + return tagged.type === 'category' ? {...tagged, items: tag(tagged.items)} : tagged; + }); return tag(await defaultSidebarItemsGenerator({...args})); }; @@ -93,7 +97,7 @@ function contentDocs(options: Options): PluginConfig { ...options, // Docusaurus appends each page's repo-relative path, so versioned pages link to their own copy under _versioned_docs. editUrl: 'https://github.com/hazelcast/documentation/edit/main/', - sidebarItemsGenerator: sidebarItemsGenerator(options.id ?? 'default'), + sidebarItemsGenerator, beforeDefaultRemarkPlugins: [ ...(options.beforeDefaultRemarkPlugins ?? []), [headingVariables, {pluginId: options.id}], diff --git a/src/test/docsPlugins.test.js b/src/test/docsPlugins.test.js index 45ed05bb..f0a925a9 100644 --- a/src/test/docsPlugins.test.js +++ b/src/test/docsPlugins.test.js @@ -83,9 +83,9 @@ function styledBadgeClasses () { return new Set([...css.matchAll(/\.(nav-badge-[a-z]+) > \.menu__link::after/g)].map((m) => m[1])) } -async function sidebar (frontMatterById, items, versionName = '5.7') { +async function sidebar (frontMatterById, items) { const docs = Object.entries(frontMatterById).map(([id, frontMatter]) => ({id, frontMatter})) - return configs.hazelcast.sidebarItemsGenerator({defaultSidebarItemsGenerator: async () => items, docs, version: {versionName}}) + return configs.hazelcast.sidebarItemsGenerator({defaultSidebarItemsGenerator: async () => items, docs}) } test('a beta or enterprise page gets the matching sidebar badge class, and the CSS styles it', async () => { @@ -120,11 +120,19 @@ test('a category takes the badge of its landing page, nested items are tagged, a assert.equal(noLanding.items[0].className, 'nav-badge-beta') }) -test('hide_in_snapshot drops a page from the snapshot sidebar only', async () => { - const items = [{type: 'doc', id: 'a'}, {type: 'doc', id: 'b'}] - const frontMatter = {a: {hide_in_snapshot: true}, b: {}} - assert.deepEqual((await sidebar(frontMatter, items, 'current')).map((i) => i.id), ['b']) - assert.deepEqual((await sidebar(frontMatter, items, '5.7')).map((i) => i.id), ['a', 'b']) +test('hide_in_snapshot makes a page unlisted in an unreleased snapshot only', async () => { + const unlisted = async (file, frontMatter = {hide_in_snapshot: true}) => { + const {frontMatter: parsed} = await docsPlugins.parseFrontMatter({ + filePath: path.join(site, file), + fileContent: '', + defaultParseFrontMatter: async () => ({frontMatter: {...frontMatter}, content: ''}), + }) + return parsed.unlisted === true + } + assert.equal(await unlisted('hazelcast/page.mdx'), true, 'snapshot main') + assert.equal(await unlisted('hazelcast_versioned_docs/version-5.7/page.mdx'), false, 'release') + assert.equal(await unlisted('clc/page.mdx'), false, 'main that is the newest release') + assert.equal(await unlisted('hazelcast/page.mdx', {}), false, 'no flag') }) // Version names are dotted numbers, compared numerically: 5.10 is newer than 5.9. From 64cd091c23efa4424afffc78e9f843a0355799d1 Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Wed, 18 Nov 2026 17:39:18 +0000 Subject: [PATCH 4/4] Show unlisted banner only in development --- CONTRIBUTING.md | 2 +- src/theme/ContentVisibility/index.tsx | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/theme/ContentVisibility/index.tsx diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee4efae2..f2e05359 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ Each documentation page is built from an MDX file. Each file starts with YAML fr - `sidebar_label`: the label that's shown in the side navigation. - `sidebar_position`: the position of this page within its section in the side navigation. - `slug`: used to maintain URLs from the previous documentation platform. Don't add a slug for new pages, or edit existing slugs. -- `hide_in_snapshot: true`: makes the page [unlisted](https://docusaurus.io/docs/create-doc#unlisted) in the unreleased snapshot version. An unlisted page is hidden from the side navigation, search engines, and the sitemap, and it stays reachable by its URL. The key has no effect in releases, and it has no effect on the dev server. +- `hide_in_snapshot: true`: makes the page [unlisted](https://docusaurus.io/docs/create-doc#unlisted) in the unreleased snapshot version. An unlisted page is hidden from the side navigation, search engines, and the sitemap, and it stays reachable by its URL. The key has no effect in releases. The dev server shows the page in the side navigation, with an "Unlisted page" banner. - `enterprise: true`, `beta: true`, or `experimental: true`: shows a badge at the top of the page. The `enterprise` and `beta` badges also show next to the page in the side navigation. Pages in `cloud/` and `tutorials/` can also have `cloud_title`, `cloud_tags`, and `cloud_order` keys. The Hazelcast Cloud console reads them. Do not remove or rename them. diff --git a/src/theme/ContentVisibility/index.tsx b/src/theme/ContentVisibility/index.tsx new file mode 100644 index 00000000..efb9ef80 --- /dev/null +++ b/src/theme/ContentVisibility/index.tsx @@ -0,0 +1,15 @@ +import React, {type ReactNode} from 'react'; +import ContentVisibility from '@theme-original/ContentVisibility'; +import type ContentVisibilityType from '@theme/ContentVisibility'; +import type {WrapperProps} from '@docusaurus/types'; +import {UnlistedMetadata} from '@docusaurus/theme-common'; + +type Props = WrapperProps; + +// Shows the unlisted banner in development environments only +export default function ContentVisibilityWrapper(props: Props): ReactNode { + if (process.env.NODE_ENV === 'production') { + return props.metadata.unlisted ? : null; + } + return ; +}