Group the sidebar's apps by the home page's categories (#8)

* Group the sidebar's apps by the home page's categories

* Keep the Official apps heading over the categories

The categories become smaller sub-headings under OFFICIAL APPS, the way
the home page nests them under The Craft Apps, so the sidebar still
tells the official apps from the third-party ones.
This commit is contained in:
SoldierPePe authored and GitHub committed 2026-11-07 01:11:34 -05:00
1 parent 8c9753b60e
commit 32ea6b68e3
4 files changed
+34 -10

No files matched your search

+2 -2
View File
@@ -84,9 +84,9 @@ Starlight uses the `docsLoader()` and `docsSchema()` in `src/content.config.ts`
The navigation and home page have a small amount of explicit configuration. To add an app:
1. Create its Markdown pages under `src/content/docs/apps/<slug>/` and add its icon to `public/assets/apps/`.
2. Add its slug, display name, and any non-default icon extension to `src/data/apps.mjs`. `WikiSidebar.astro` uses this list to render the icon and expandable group.
2. Add its slug, display name, and any non-default icon extension to `src/data/apps.mjs`, and add an official app's slug to its category in `appCategories` there. `WikiSidebar.astro` uses these lists to render the icon and expandable group under its category; the build stops if an official app has no category.
3. Add a matching app group in `astro.config.mjs` and a collection in `public/admin/config.yml` so Starlight and Sveltia can find its pages.
4. Add an icon card to `src/content/docs/index.mdx` and update its app count.
4. Add an icon card to the same category in `src/content/docs/index.mdx` and update its app count.
5. Run `npm run build` and check the home page, app links, and `/admin/`.
The custom sidebar uses the `guides` list in `src/data/apps.mjs` for its links. If guide filenames or the set of guides change, update that list too. Pages an app has beyond the five shared guides, such as WordCraft's Zotero page, go in `extraGuides` under the app's slug; the sidebar lists them before Troubleshooting. Give them `sidebar.order` in their frontmatter too, so the previous and next links follow the same order. Pages that the sidebar nests under one guide, such as VectorCraft's task guides under Workflows, go in `childGuides` under the app's slug and then the guide's slug. The sidebar lists them under that guide's link and expands the list on the guide and on each of its pages. Give them `sidebar.order` values between the guide's and the next page's, so the previous and next links visit them right after the guide. Starlight's autogenerated sidebar configuration does not by itself add links to the custom sidebar.
+16 -8
View File
@@ -1,19 +1,27 @@
---
import { apps, thirdPartyApps } from '../data/apps.mjs';
import { apps, appCategories, thirdPartyApps } from '../data/apps.mjs';
import WikiGuideLinks from './WikiGuideLinks.astro';
const pathname = Astro.url.pathname;
const appBySlug = Object.fromEntries(apps.map((app) => [app[0], app]));
---
<div class="wiki-sidebar-inner">
<label class="wiki-search-label" for="wiki-app-search">Find an app</label>
<input id="wiki-app-search" type="search" placeholder="Search apps..." autocomplete="off" />
<a href="/" class:list={['wiki-home-link', { active: pathname === '/' }]}>All documentation</a>
<p class="wiki-sidebar-label">OFFICIAL APPS</p>
<div id="wiki-app-list">
{apps.map(([slug, name, ext = 'webp']) => (
<details class="wiki-app-group" data-name={name.toLowerCase()} open={pathname.startsWith(`/apps/${slug}/`)}>
<summary><img src={`/assets/apps/${slug}.${ext}`} alt="" /><span>{name}</span><span class="wiki-chevron" aria-hidden="true">⌄</span></summary>
<WikiGuideLinks slug={slug} />
</details>
<div class="wiki-official-apps">
{appCategories.map(([category, slugs]) => (
<>
<p class="wiki-sidebar-category">{category}</p>
<div class="wiki-app-list">
{slugs.map((slug) => appBySlug[slug]).map(([slug, name, ext = 'webp']) => (
<details class="wiki-app-group" data-name={name.toLowerCase()} open={pathname.startsWith(`/apps/${slug}/`)}>
<summary><img src={`/assets/apps/${slug}.${ext}`} alt="" /><span>{name}</span><span class="wiki-chevron" aria-hidden="true">⌄</span></summary>
<WikiGuideLinks slug={slug} />
</details>
))}
</div>
</>
))}
</div>
<p class="wiki-sidebar-label">THIRD-PARTY APPS</p>
@@ -30,7 +38,7 @@ const pathname = Astro.url.pathname;
<script>
const search = document.querySelector<HTMLInputElement>('#wiki-app-search');
const groups = document.querySelectorAll<HTMLElement>('.wiki-app-group');
const labels = document.querySelectorAll<HTMLElement>('.wiki-sidebar-label');
const labels = document.querySelectorAll<HTMLElement>('.wiki-sidebar-label, .wiki-sidebar-category');
const noResults = document.querySelector<HTMLElement>('#wiki-no-results');
search?.addEventListener('input', () => {
const query = search.value.trim().toLowerCase();
+14
View File
@@ -7,6 +7,20 @@ export const apps = [
['cadcraft', 'CADCraft'], ['gridcraft', 'GridCraft'], ['craft-anything', 'Craft Anything'],
];
// The home page's app categories, in its order; the sidebar groups the official apps by them.
export const appCategories = [
['AI and generative media', ['artcraft-studio']],
['Graphics and design', ['photocraft', 'vectorcraft', 'lightcraft', 'designcraft', 'figcraft', 'texturecraft', 'materialcraft']],
['Video and effects', ['filmcraft', 'effectcraft']],
['Audio', ['soundcraft']],
['CAD and drafting', ['cadcraft']],
['Office', ['wordcraft', 'gridcraft', 'deckcraft', 'pdfcraft']],
['Developer tools', ['craft-anything']],
];
// An official app without a category would vanish from the sidebar: stop the build instead.
const uncategorized = apps.filter(([slug]) => !appCategories.some(([, slugs]) => slugs.includes(slug)));
if (uncategorized.length) throw new Error(`Add to appCategories in src/data/apps.mjs: ${uncategorized.map(([slug]) => slug).join(', ')}`);
export const thirdPartyApps = [
['solidcraft', 'SolidCraft', 'png'],
];
+2
View File
@@ -33,6 +33,8 @@
.wiki-sidebar-label, .wiki-eyebrow { color:#b9cbff; font:600 11px/1.5 'Geist Mono Variable', monospace; letter-spacing:.14em; }
.wiki-sidebar-label { padding:0 10px; color:#858895; margin-bottom:12px; }
.wiki-sidebar-label:not(:first-of-type) { margin-top:24px; }
.wiki-sidebar-category { padding:0 10px; margin:14px 0 2px; color:#858895; font-size:12px; font-weight:500; }
.wiki-sidebar-category:first-child { margin-top:0; }
.wiki-app-group summary { display:flex; align-items:center; gap:10px; padding:8px 10px; cursor:pointer; list-style:none; font-size:14px; border-radius:5px; }
.wiki-app-group summary::-webkit-details-marker { display:none; }
.wiki-app-group summary:hover, .wiki-guide-links a:hover { background:#1b1c24; }