@@ -9,30 +9,9 @@ const outDir = path.join(root, "dist", "docs-site");
99const repoUrl = "https://github.com/openclaw/clawsweeper" ;
1010const repoEditBase = `${ repoUrl } /edit/main/docs` ;
1111const customDomain = "clawsweeper.bot" ;
12-
13- const sections = [
14- [ "Start" , [ "README.md" , "scheduler.md" , "work-lane.md" ] ] ,
15- [
16- "Lanes" ,
17- [
18- "commit-sweeper.md" ,
19- "target-dispatcher.md" ,
20- "pr-review-comments.md" ,
21- "openclaw-event-hooks.md" ,
22- ] ,
23- ] ,
24- [
25- "Repair" ,
26- [
27- "repair/README.md" ,
28- "repair/operations.md" ,
29- "repair/automatic-issue-prs.md" ,
30- "repair/auto-update-prs.md" ,
31- "repair/automerge-flow.md" ,
32- "repair/internal-features.md" ,
33- ] ,
34- ] ,
35- ] ;
12+ const siteManifest = JSON . parse (
13+ fs . readFileSync ( path . join ( root , "config" , "documentation-site.json" ) , "utf8" ) ,
14+ ) ;
3615
3716fs . rmSync ( outDir , { recursive : true , force : true } ) ;
3817fs . mkdirSync ( outDir , { recursive : true } ) ;
@@ -41,7 +20,15 @@ const pages = allMarkdown(docsDir).map((file) => {
4120 const rel = path . relative ( docsDir , file ) . replaceAll ( path . sep , "/" ) ;
4221 const markdown = fs . readFileSync ( file , "utf8" ) ;
4322 const title = firstHeading ( markdown ) || titleize ( path . basename ( rel , ".md" ) ) ;
44- return { file, rel, title, outRel : outPath ( rel ) , markdown, synthetic : false } ;
23+ return {
24+ file,
25+ rel,
26+ title,
27+ outRel : outPath ( rel ) ,
28+ markdown,
29+ synthetic : false ,
30+ lifecycle : lifecycleFor ( rel ) ,
31+ } ;
4532} ) ;
4633
4734const homePage = {
@@ -51,21 +38,23 @@ const homePage = {
5138 outRel : "index.html" ,
5239 markdown : "" ,
5340 synthetic : true ,
41+ lifecycle : { canonical : true , name : "active" } ,
5442} ;
5543pages . unshift ( homePage ) ;
5644
5745const pageMap = new Map ( pages . map ( ( page ) => [ page . rel , page ] ) ) ;
58- const nav = sections
59- . map ( ( [ name , rels ] ) => ( {
60- name,
61- pages : rels . map ( ( rel ) => pageMap . get ( rel ) ) . filter ( Boolean ) ,
46+ const nav = siteManifest . sections
47+ . map ( ( section ) => ( {
48+ name : section . name ,
49+ pages : section . pages . map ( ( rel ) => pageMap . get ( rel ) ) . filter ( Boolean ) ,
6250 } ) )
6351 . filter ( ( section ) => section . pages . length ) ;
6452
6553const sectionByRel = new Map ( ) ;
6654for ( const section of nav )
6755 for ( const page of section . pages ) sectionByRel . set ( page . rel , section . name ) ;
6856const orderedPages = [ homePage , ...nav . flatMap ( ( s ) => s . pages ) ] ;
57+ const canonicalPages = orderedPages ;
6958
7059for ( const page of pages ) {
7160 const html = page . synthetic ? "" : markdownToHtml ( page . markdown , page . rel ) ;
@@ -89,7 +78,7 @@ fs.writeFileSync(
8978 `User-agent: *\nAllow: /\nSitemap: https://${ customDomain } /sitemap.xml\n` ,
9079 "utf8" ,
9180) ;
92- fs . writeFileSync ( path . join ( outDir , "sitemap.xml" ) , sitemap ( orderedPages ) , "utf8" ) ;
81+ fs . writeFileSync ( path . join ( outDir , "sitemap.xml" ) , sitemap ( canonicalPages ) , "utf8" ) ;
9382fs . writeFileSync ( path . join ( outDir , "llms.txt" ) , llmsTxt ( ) , "utf8" ) ;
9483console . log ( `built docs site: ${ path . relative ( root , outDir ) } (${ pages . length } pages)` ) ;
9584
@@ -120,11 +109,22 @@ function llmsTxt() {
120109}
121110
122111function docsLlmsPages ( ) {
123- const seen = new Set ( ) ;
124- const ordered = typeof orderedPages !== "undefined" ? orderedPages : [ ] ;
125- return [ ...ordered , ...pages ] . filter (
126- ( page ) => page . outRel && ! seen . has ( page . outRel ) && seen . add ( page . outRel ) ,
112+ return canonicalPages ;
113+ }
114+
115+ function lifecycleFor ( rel ) {
116+ const canonical = siteManifest . sections . some ( ( section ) => section . pages . includes ( rel ) ) ;
117+ const matches = siteManifest . noncanonical . filter (
118+ ( entry ) => entry . path === rel || ( entry . prefix && rel . startsWith ( entry . prefix ) ) ,
127119 ) ;
120+ if ( canonical && matches . length )
121+ throw new Error ( `documentation page has conflicting lifecycle: ${ rel } ` ) ;
122+ if ( canonical ) return { canonical : true , name : "active" } ;
123+ if ( matches . length === 1 )
124+ return { canonical : false , name : matches [ 0 ] . lifecycle , banner : matches [ 0 ] . banner } ;
125+ if ( matches . length > 1 )
126+ throw new Error ( `documentation page has multiple lifecycle matches: ${ rel } ` ) ;
127+ throw new Error ( `documentation page is not classified in config/documentation-site.json: ${ rel } ` ) ;
128128}
129129
130130function docsOrigin ( ) {
@@ -409,6 +409,7 @@ function layout({ page, html, toc, prev, next, sectionName }) {
409409 <meta name="viewport" content="width=device-width, initial-scale=1">
410410 <title>${ escapeHtml ( page . title ) } ${ isHome ? " - Conservative maintenance bot" : " - ClawSweeper Docs" } </title>
411411 <meta name="description" content="${ escapeAttr ( description ) } ">
412+ ${ page . lifecycle . canonical ? "" : '<meta name="robots" content="noindex, follow">' }
412413 <meta name="theme-color" content="#f4ead7">
413414 <meta property="og:title" content="${ escapeAttr ( page . title ) } ${ isHome ? " - ClawSweeper" : " - ClawSweeper docs" } ">
414415 <meta property="og:description" content="${ escapeAttr ( description ) } ">
@@ -483,7 +484,11 @@ function standardHero(page, sectionName, editUrl) {
483484 <a class="repo" href="${ repoUrl } " rel="noopener">GitHub</a>
484485 <a class="edit" href="${ escapeAttr ( editUrl ) } " rel="noopener">Edit page</a>
485486 </div>
486- </header>` ;
487+ </header>${
488+ page . lifecycle . canonical
489+ ? ""
490+ : `<aside class="lifecycle-banner" role="note"><strong>${ escapeHtml ( page . lifecycle . name ) } </strong>: ${ escapeHtml ( page . lifecycle . banner ) } </aside>`
491+ } `;
487492}
488493
489494function landingHero ( rootPrefix ) {
0 commit comments