Skip to content

Commit ae7dce7

Browse files
committed
Drop the section names that were doing nothing
`blog` and `examples` title-case to exactly the strings the map returned, so only `docs` -> `Documentation` was ever a real rename. Section names now come from the folder a page lives in, with that one exception. Output is unchanged for every path shape: docs/ still gives Documentation, blog/ still gives Blog, examples/ still gives Examples.
1 parent e6ea243 commit ae7dce7

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

docs/plugins/swm-geo.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ const fs = require('node:fs');
22
const path = require('node:path');
33

44
const ORGANIZATION_ID = 'https://swmansion.com/#organization';
5-
const SECTIONS = { docs: 'Documentation', blog: 'Blog', examples: 'Examples' };
5+
// Section names come from the folder a page lives in. `docs` is the only
6+
// segment worth renaming - `blog` and `examples` already title-case to
7+
// themselves, so listing them bought nothing.
8+
const SECTION_NAMES = { docs: 'Documentation' };
69
const ACRONYMS = { api: 'API', ui: 'UI' };
710

811
const titleCase = (segment) =>
@@ -11,11 +14,9 @@ const titleCase = (segment) =>
1114
.map((word) => ACRONYMS[word] ?? word.replace(/^./, (c) => c.toUpperCase()))
1215
.join(' ');
1316

14-
// With `routeBasePath: '/'` there is no `docs/` prefix to match, so group by
15-
// the folder the page lives in instead of dropping everything into `Pages`.
1617
const sectionOf = (relative) => {
1718
const parts = relative.split('/').filter(Boolean);
18-
if (SECTIONS[parts[0]]) return SECTIONS[parts[0]];
19+
if (SECTION_NAMES[parts[0]]) return SECTION_NAMES[parts[0]];
1920
if (parts.length < 2) return 'Pages';
2021
return titleCase(parts[0]);
2122
};
@@ -105,11 +106,11 @@ function buildLlmsTxt({ siteConfig, routesPaths, readPage }) {
105106
const lines = [`# ${title}`];
106107
if (tagline) lines.push('', `> ${tagline}`);
107108

108-
const preferred = ['Documentation', 'Examples', 'Blog'];
109+
// Documentation first, the rest alphabetically, loose pages last.
109110
const order = [
110-
...preferred.filter((section) => grouped.has(section)),
111+
...(grouped.has('Documentation') ? ['Documentation'] : []),
111112
...[...grouped.keys()]
112-
.filter((section) => !preferred.includes(section) && section !== 'Pages')
113+
.filter((section) => section !== 'Documentation' && section !== 'Pages')
113114
.sort(),
114115
...(grouped.has('Pages') ? ['Pages'] : []),
115116
];

0 commit comments

Comments
 (0)