Skip to content

Commit 979ab69

Browse files
isadeksbgagentkrokoko
authored
docs: fix broken site images + in-body links + Slack app-install wording (#90) (#314)
* docs: fix broken site images + in-body links + Slack app-install wording (#90) Three docs-site fixes: 1. Missing Slack setup images (the #90 report). The sync script rewrites `../imgs/foo.png` to an absolute `/<base>/imgs/foo.png` URL served from `docs/public/`, but never copied `docs/imgs/` → `docs/public/imgs/` — so the four Slack screenshots 404'd on the published site. Add a `copyAssetDir` step that mirrors source `imgs/` and `diagrams/` into `public/`, and commit the copied assets. Prevents recurrence for any future image. 2. Broken in-body design-doc links site-wide. `rewriteDocsLinkTarget` emitted bare root-relative routes (`/architecture/foo`) with no base prefix, so they resolved to the domain root and 404'd under the project base path. Starlight prefixes its own nav links automatically but not our rewritten markdown-body links. Prepend `docsBase` to every rewritten target (same prefix the image rewrite already uses). Re-synced all mirrors — the large diff is purely the base-path prefix on existing links. 3. Reword the Slack prerequisite away from "use a personal free workspace if your corporate Slack restricts app installs" — we don't want to suggest bypassing org controls. Now points users to request admin approval through their Slack administrator. * docs: redact app/client IDs, verification token, and API Gateway ID in Slack setup screenshots * docs: remove unreachable anchor guard in link rewrite (review nit) --------- Co-authored-by: bgagent <bgagent@noreply.github.com> Co-authored-by: Alain Krok <alkrok@amazon.com>
1 parent ab27dc8 commit 979ab69

56 files changed

Lines changed: 229 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/guides/SLACK_SETUP_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This guide walks through setting up the ABCA Slack integration. Once configured,
66

77
- ABCA CDK stack deployed (see [Developer guide](./DEVELOPER_GUIDE.md))
88
- A Cognito user account configured (see [User guide](./USER_GUIDE.md))
9-
- A Slack workspace where you can install apps (use a personal free workspace if your corporate Slack restricts app installs)
9+
- A Slack workspace where you are authorized to install apps (if your workspace requires admin approval for app installs, request it through your Slack administrator)
1010
- AWS CLI configured with credentials for your ABCA account
1111

1212
## Quick start

docs/imgs/enable-events-after.png

-19.1 KB
Loading

docs/imgs/enable-events-before.png

-19.9 KB
Loading

docs/imgs/find-credentials.png

-70.8 KB
Loading
-78.1 KB
Loading
102 KB
Loading
104 KB
Loading
253 KB
Loading
262 KB
Loading

docs/scripts/sync-starlight.mjs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,19 @@ function ensureFrontmatter(content, title) {
100100
.replaceAll('../diagrams/', `${docsBase}/diagrams/`)
101101
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, label, target) => {
102102
const rewritten = rewriteDocsLinkTarget(target);
103-
return rewritten ? `[${label}](${rewritten})` : match;
103+
if (!rewritten) {
104+
return match;
105+
}
106+
// The site is served under `base` (docsBase), so root-relative routes
107+
// must carry that prefix — otherwise they resolve to the domain root
108+
// and 404. Starlight prefixes its own nav links automatically, but our
109+
// rewritten body links are raw markdown and need it added explicitly
110+
// (same reason the image rewrites above include docsBase). Every
111+
// non-undefined return from rewriteDocsLinkTarget is a `/…` route (bare
112+
// `#…` anchors and external links return undefined and keep their
113+
// original text above), so the prefix always applies.
114+
// (Fixes the broken in-body design-doc links.)
115+
return `[${label}](${docsBase}${rewritten})`;
104116
});
105117

106118
const trimmed = normalized.trimStart();
@@ -158,6 +170,25 @@ function mirrorDirectory(sourceDir, targetDirRelative) {
158170
}
159171
}
160172

173+
// Recursively copy a source asset directory into the site's public/ tree so
174+
// every committed image/diagram is served at its rewritten absolute URL.
175+
// Filenames are preserved verbatim (markdown references them as-is).
176+
function copyAssetDir(sourceDir, targetDir) {
177+
if (!fs.existsSync(sourceDir)) {
178+
return;
179+
}
180+
fs.mkdirSync(targetDir, { recursive: true });
181+
for (const entry of fs.readdirSync(sourceDir, { withFileTypes: true })) {
182+
const from = path.join(sourceDir, entry.name);
183+
const to = path.join(targetDir, entry.name);
184+
if (entry.isDirectory()) {
185+
copyAssetDir(from, to);
186+
} else if (entry.isFile()) {
187+
fs.copyFileSync(from, to);
188+
}
189+
}
190+
}
191+
161192
function splitGuide(sourcePath, targetDirRelative, introTitle) {
162193
if (!fs.existsSync(sourcePath)) {
163194
return;
@@ -287,5 +318,12 @@ mirrorDirectory(path.join(docsRoot, 'design'), path.join('src', 'content', 'docs
287318
// --- Decision records (ADRs): mirror to decisions/ ---
288319
mirrorDirectory(path.join(docsRoot, 'decisions'), path.join('src', 'content', 'docs', 'decisions'));
289320

321+
// --- Static assets: copy source image dir into the site's public/ ---
322+
// Guides reference images as `../imgs/foo.png`; ensureFrontmatter() turns
323+
// those into absolute `/<base>/imgs/foo.png` URLs, which Astro serves from
324+
// public/. Copy the source dir here so every committed image is published —
325+
// otherwise a new image lands in docs/imgs/ but 404s on the site (#90).
326+
copyAssetDir(path.join(docsRoot, 'imgs'), path.join(docsRoot, 'public', 'imgs'));
327+
290328
// Guardrail: ensure target tree exists when running in a clean checkout.
291329
fs.mkdirSync(targetRoot, { recursive: true });

0 commit comments

Comments
 (0)