This is an automated email from the ASF dual-hosted git repository.

zfc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-website.git


The following commit(s) were added to refs/heads/master by this push:
     new a4893097e Add sidebar for index pages of each repo and community pages 
(#28)
a4893097e is described below

commit a4893097ee212c7be02a67302af08a77fb92677f
Author: Glass Panel <[email protected]>
AuthorDate: Fri Jul 18 20:33:40 2025 +0800

    Add sidebar for index pages of each repo and community pages (#28)
    
    * Update dependency
    
    * Add sidebar for index doc of each repo
    
    * Move community pages to docs/ to provide sidebar
    
    * Cleanup console.logs
    
    * Update denpendency
    
    * Cleanup
    
    * Update Navbar item link
    
    * Tweak community page sidebar order
    
    * Cleanup
    
    * Reorder sidebar items according to navbar
---
 .gitignore                                         |  3 +-
 .../pages => docs/community}/becoming-a-member.md  |  1 -
 site/{src/pages => docs/community}/community.md    |  1 -
 site/{src/pages => docs/community}/contributing.md |  1 -
 site/{src/pages => docs/community}/contributors.md |  1 -
 site/{src/pages => docs/community}/maturity.md     |  1 -
 .../{src/pages => docs/community}/release-guide.md |  1 -
 site/docusaurus.config.js                          | 28 +++++++---
 site/package-lock.json                             |  6 +--
 site/package.json                                  |  3 +-
 site/sidebars.js                                   | 59 +++++++++++++++++-----
 11 files changed, 76 insertions(+), 29 deletions(-)

diff --git a/.gitignore b/.gitignore
index 97cb6630f..4141ce3b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@ target
 sgx-sdk-docs/Cargo.lock
 .docusaurus
 Cargo.lock
-docs
\ No newline at end of file
+site/docs/*
+!site/docs/community
\ No newline at end of file
diff --git a/site/src/pages/becoming-a-member.md 
b/site/docs/community/becoming-a-member.md
similarity index 99%
rename from site/src/pages/becoming-a-member.md
rename to site/docs/community/becoming-a-member.md
index 54e7acfe8..df540b9e6 100644
--- a/site/src/pages/becoming-a-member.md
+++ b/site/docs/community/becoming-a-member.md
@@ -1,6 +1,5 @@
 ---
 permalink: /becoming-a-member
-sidebar: false
 ---
 
 # Becoming a Committer or PPMC Member of Apache Teaclave
diff --git a/site/src/pages/community.md b/site/docs/community/community.md
similarity index 99%
rename from site/src/pages/community.md
rename to site/docs/community/community.md
index 5d473651a..c043c12f9 100644
--- a/site/src/pages/community.md
+++ b/site/docs/community/community.md
@@ -1,6 +1,5 @@
 ---
 permalink: /community
-sidebar: false
 ---
 
 # Community
diff --git a/site/src/pages/contributing.md 
b/site/docs/community/contributing.md
similarity index 97%
rename from site/src/pages/contributing.md
rename to site/docs/community/contributing.md
index ec24bb1cd..073df8fdb 100644
--- a/site/src/pages/contributing.md
+++ b/site/docs/community/contributing.md
@@ -1,6 +1,5 @@
 ---
 permalink: /contributing
-sidebar: false
 ---
 
 # Contributing
diff --git a/site/src/pages/contributors.md 
b/site/docs/community/contributors.md
similarity index 99%
rename from site/src/pages/contributors.md
rename to site/docs/community/contributors.md
index 80c3673f2..10f788abc 100644
--- a/site/src/pages/contributors.md
+++ b/site/docs/community/contributors.md
@@ -1,6 +1,5 @@
 ---
 permalink: /contributors
-sidebar: false
 ---
 
 # Contributors
diff --git a/site/src/pages/maturity.md b/site/docs/community/maturity.md
similarity index 99%
rename from site/src/pages/maturity.md
rename to site/docs/community/maturity.md
index 63e07aafc..295819554 100644
--- a/site/src/pages/maturity.md
+++ b/site/docs/community/maturity.md
@@ -1,6 +1,5 @@
 ---
 permalink: /maturity
-sidebar: false
 ---
 
 # Maturity Assessment For The Teaclave Ecosystem
diff --git a/site/src/pages/release-guide.md 
b/site/docs/community/release-guide.md
similarity index 99%
rename from site/src/pages/release-guide.md
rename to site/docs/community/release-guide.md
index dc242a5cc..29d5e4845 100644
--- a/site/src/pages/release-guide.md
+++ b/site/docs/community/release-guide.md
@@ -1,6 +1,5 @@
 ---
 permalink: /release-guide
-sidebar: false
 ---
 
 # Release Guide
diff --git a/site/docusaurus.config.js b/site/docusaurus.config.js
index e485c8474..162e64447 100644
--- a/site/docusaurus.config.js
+++ b/site/docusaurus.config.js
@@ -4,6 +4,7 @@
 // There are various equivalent ways to declare your Docusaurus config.
 // See: https://docusaurus.io/docs/api/docusaurus-config
 
+import path from 'path';
 import { themes as prismThemes } from 'prism-react-renderer';
 
 // This runs in Node.js - Don't use client-side code here (browser APIs, 
JSX...)
@@ -38,6 +39,19 @@ const config = {
     parseFrontMatter: async (params) => {
       const result = await params.defaultParseFrontMatter(params);
       result.frontMatter.slug = result.frontMatter.permalink;
+      // Add sidebar for index docs
+      const indexDocs = {
+        './docs/teaclave-docs/README.md': 'teaclave',
+        './docs/teaclave-sgx-sdk/documents/README.md': 'teaclave-sgx-sdk',
+        './docs/teaclave-trustzone-sdk/docs/README.md': 
'teaclave-trustzone-sdk',
+        './docs/teaclave-faas-legacy/docs/README.md': 'teaclave-faas-legacy',
+      };
+      Object.keys(indexDocs).forEach((key) => {
+        if (path.resolve(params.filePath) == path.resolve(key)) {
+          result.frontMatter.displayed_sidebar = `${indexDocs[key]}_sidebar`;
+        }
+      }); 
+
       return result;
     },
     // Replace autolinks to avoid mdx rendering issues.
@@ -81,6 +95,7 @@ const config = {
             '*.md',
             'api-docs/*.md',
             'blog/*.md',
+            'community/*.md',
             'teaclave-docs/**/*.md',
             'teaclave-faas-legacy/**/*.md',
             'teaclave-sgx-sdk/documents/*.md',
@@ -139,17 +154,18 @@ const config = {
             to: '/community',
             label: 'Community',
             items: [
-              { label: 'Contributing', to: '/contributing' },
-              { label: 'Contributors', to: '/contributors' },
-              { label: 'Becoming a Member', to: '/becoming-a-member' },
-              { label: 'Maturity Assessment', to: '/maturity' },
-              { label: 'Release Guide', to: '/release-guide' },
+              { label: 'Contributing', to: '/contributing', file: 
'community/contributing.md' },
+              { label: 'Contributors', to: '/contributors', file: 
'community/contributors.md' },
+              { label: 'Becoming a Member', to: '/becoming-a-member', file: 
'community/becoming-a-member.md' },
+              { label: 'Maturity Assessment', to: '/maturity', file: 
'community/maturity.md' },
+              { label: 'Release Guide', to: '/release-guide', file: 
'community/release-guide.md' },
             ],
+            file: 'community/community.md',
             position: 'right',
           },
           { to: '/download', label: 'Download', position: 'right' },
           {
-            to: '/docs',
+            to: '/teaclave-docs',
             label: 'Docs',
             items: [
               { label: 'Teaclave', to: '/teaclave-docs/' },
diff --git a/site/package-lock.json b/site/package-lock.json
index 26ef1ec1c..7b64d15fd 100644
--- a/site/package-lock.json
+++ b/site/package-lock.json
@@ -12468,9 +12468,9 @@
       }
     },
     "node_modules/on-headers": {
-      "version": "1.0.2",
-      "resolved": 
"https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz";,
-      "integrity": 
"sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==",
+      "version": "1.1.0",
+      "resolved": 
"https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz";,
+      "integrity": 
"sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==",
       "license": "MIT",
       "engines": {
         "node": ">= 0.8"
diff --git a/site/package.json b/site/package.json
index 5b440ace2..52c6e050e 100644
--- a/site/package.json
+++ b/site/package.json
@@ -23,7 +23,8 @@
     "react-dom": "^19.0.0"
   },
   "overrides": {
-    "webpack-dev-server": "^5.2.2"
+    "webpack-dev-server": "^5.2.2",
+    "on-headers": ">=1.1.0"
   },
   "devDependencies": {
     "@docusaurus/module-type-aliases": "3.8.1",
diff --git a/site/sidebars.js b/site/sidebars.js
index c1ed42c99..d6903df0e 100644
--- a/site/sidebars.js
+++ b/site/sidebars.js
@@ -17,6 +17,7 @@
 
 import * as fs from 'fs';
 import * as path from 'path';
+import config from './docusaurus.config';
 
 /** @returns {{title: string, items: { name: string, link: string }[]}[]} */
 function parseTOC(content = '') {
@@ -54,7 +55,7 @@ function sidebarItemFromTOCItem(item, relpath) {
       href: item.link,
       label: item.name,
     };
-  } else if(item.link.endsWith('.md')) {
+  } else if (item.link.endsWith('.md')) {
     try {
       fs.statSync('./docs/' + path.join(relpath, item.link));
     } catch (stat) {
@@ -71,7 +72,30 @@ function sidebarItemFromTOCItem(item, relpath) {
     // If the link is not a markdown file or a URL, we ignore it.
     return undefined;
   }
-    
+
+}
+
+function sidebarItemFromNavbarItem(item) {
+  if (item.file)
+    return ({
+      type: 'doc',
+      id: item.file.replace(/.md$/, ''),
+      label: item.label,
+    });
+  else if (item.href)
+    return ({
+      type: 'link',
+      href: item.href,
+      label: item.label,
+    });
+  else if (item.to)
+    return ({
+      type: 'link',
+      href: item.to,
+      label: item.label,
+    });
+  else
+    throw new Error(`Unknown navbar item format: ${JSON.stringify(item)}`);
 }
 
 const repos = {
@@ -93,15 +117,26 @@ const repos = {
   ]),
 };
 
-const sidebars = Object.fromEntries(
-  Object.entries(repos).map(([name, repo]) => [
-    `${name}_sidebar`,
-    repo.map(([title, items]) => ({
-      type: 'category',
-      label: title,
-      items: items
-    }))
-  ])
-);
+// Get rid of type annotation error
+const navbar = Object.assign(Object.create({}), config.themeConfig?.navbar);
+const communityNav = navbar.items?.find(item => item.label == 'Community');
+
+const sidebars = {
+  ...Object.fromEntries(
+    Object.entries(repos).map(([name, repo]) => [
+      `${name}_sidebar`,
+      repo.map(([title, items]) => ({
+        type: 'category',
+        label: title,
+        items: items
+      }))
+    ])
+  ),
+  'community_sidebar': [
+    sidebarItemFromNavbarItem(communityNav)
+  ].concat(communityNav.items
+    .map(item => sidebarItemFromNavbarItem(item))
+  ),
+};
 
 export default sidebars;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to