Skip to content

Commit 1d5a201

Browse files
Add external project sidebar stubs and redirect logic via sources.external.json
1 parent 28b237b commit 1d5a201

4 files changed

Lines changed: 79 additions & 0 deletions

File tree

.github/workflows/pages.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- name: Import external docs
3737
run: bash scripts/import_sources.sh
3838

39+
- name: Generate external project stubs
40+
run: python3 scripts/generate_external_redirects.py
41+
3942
- name: Build with Jekyll
4043
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
4144
env:

projects/external.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
layout: page
3+
title: External Projects
4+
permalink: /projects/external/
5+
parent: Projects
6+
has_children: true
7+
nav_order: 2
8+
---
9+
10+
The following external projects are rendered in their own GitHub Pages sites but are listed here for navigation purposes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Generate redirect stub pages for external projects.
4+
Each page redirects to a GitHub Pages site and is nested under 'Projects > External Projects'.
5+
"""
6+
7+
import json
8+
from pathlib import Path
9+
10+
CONFIG = Path("sources.external.json")
11+
OUT_DIR = Path("docs/projects/external")
12+
13+
14+
def main():
15+
with CONFIG.open("r", encoding="utf-8") as f:
16+
data = json.load(f)
17+
18+
projects = data.get("external_projects", [])
19+
OUT_DIR.mkdir(parents=True, exist_ok=True)
20+
21+
for i, proj in enumerate(projects, 1):
22+
name = proj["name"]
23+
title = proj.get("title", name)
24+
url = proj["url"]
25+
path = OUT_DIR / f"{name}.md"
26+
27+
content = f"""---
28+
layout: redirect
29+
title: {title}
30+
parent: External Projects
31+
grand_parent: Projects
32+
nav_order: {i}
33+
redirect_to: {url}
34+
---
35+
"""
36+
37+
path.write_text(content.strip() + "\n", encoding="utf-8")
38+
print(f"✔ Generated redirect: {path}")
39+
40+
41+
if __name__ == "__main__":
42+
main()

sources.external.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"external_projects": [
3+
{
4+
"name": "Slice_TEMP",
5+
"title": "Slice TEMP",
6+
"url": "/Slice_TEMP/"
7+
},
8+
{
9+
"name": "Slice_DCMT",
10+
"title": "Slice DCMT",
11+
"url": "/Slice_DCMT/"
12+
},
13+
{
14+
"name": "can-nano-shield",
15+
"title": "CAN Nano Shield",
16+
"url": "/can-nano-shield/"
17+
},
18+
{
19+
"name": "can-nano-shield-fieldbus",
20+
"title": "CAN Nano Fieldbus",
21+
"url": "/can-nano-shield-fieldbus/"
22+
}
23+
]
24+
}

0 commit comments

Comments
 (0)