Skip to content

Commit

Permalink
Add possibility to hide documentation pages
Browse files Browse the repository at this point in the history
Fixes #167
  • Loading branch information
michel-kraemer committed Nov 30, 2024
1 parent 956dd5f commit 4a23038
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/sitemap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export default function sitemap(): MetadataRoute.Sitemap {
for (let version of filteredVersions) {
let toc = makeToc("docs", version)
for (let chapter of toc) {
let filteredPages = chapter.pages.filter(page => !isExternal(page.slug))
let filteredPages = chapter.pages.filter(
page => !isExternal(page.slug) && page.hidden !== true,
)
for (let page of filteredPages) {
let slug = page.slug
if (slug !== "") {
Expand Down
5 changes: 4 additions & 1 deletion components/docs/SidebarLeft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ function createToc(
<li key={titleSlug}>
<div className="mb-2 font-normal text-gray-900">{chapter.title}</div>
<ul className="flex flex-col gap-2 border-l border-gray-200">
{chapter.pages.map(p => {
{chapter.pages.flatMap(p => {
let ext = isExternal(p.slug)
if (p.hidden ?? false) {
return []
}
return (
<li
key={p.slug}
Expand Down
2 changes: 2 additions & 0 deletions components/docs/Toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Page {
readonly title: string
readonly slug: string
readonly label?: string
readonly hidden?: boolean
readonly edit?: string
readonly examples?: string
readonly includeBook?: boolean
Expand Down Expand Up @@ -256,6 +257,7 @@ function makeChapters(
title: e.name,
slug: pageSlug,
label: e.label,
hidden: e.hidden,
edit: e.edit,
examples: e.examples,
sections,
Expand Down
1 change: 1 addition & 0 deletions docs/metadata/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Doc {
edit: string
examples?: string
label?: string
hidden?: boolean
}

export interface GuidesDoc extends Doc {
Expand Down
4 changes: 4 additions & 0 deletions scraper/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ async function workerMain({ version }: { version: string }) {
// skip external pages
continue
}
if (e.hidden ?? false) {
// skip hidden pages
continue
}
let slug = e.href
if (slug.startsWith("/")) {
slug = slug.substring(1)
Expand Down

0 comments on commit 4a23038

Please sign in to comment.