Skip to content

Rewrite cross-note .md links to Jekyll permalinks at build time#9

Merged
herohua merged 1 commit into
mainfrom
fix-publish-rewrite-note-links
May 28, 2026
Merged

Rewrite cross-note .md links to Jekyll permalinks at build time#9
herohua merged 1 commit into
mainfrom
fix-publish-rewrite-note-links

Conversation

@herohua
Copy link
Copy Markdown
Owner

@herohua herohua commented May 28, 2026

Summary

Currently the build script only rewrites image paths. Cross-note links like `taste` are emitted verbatim, so they 404 on the published Jekyll site (which serves posts at `/{stem}` per the site's `/:title` permalink config).

This patch adds a regex pass over each note's body that rewrites `label` (with optional leading `./`) to `label`. Anchors are preserved. Image links are excluded by the leading-`!` lookbehind.

A first pass collects the set of stems whose front matter has `publish: true`. Links to non-publishable or missing targets are left untouched and logged as a WARN to stderr — useful signal without breaking the build.

Test plan

  • Local run against current `notes/` (including the new `growing-as-an-engineer-in-the-ai-era.md` from Add note: Growing as an engineer in the AI era #8): both `taste-in-software.md` and `evaluating-a-self-healing-content-agent.md#3-...` rewrote to `/taste-in-software` and `/evaluating-a-self-healing-content-agent#3-...`. No false positives elsewhere in the body.
  • Image rewrite still works (the existing `IMAGE_PATH_RE` pass is unchanged and runs first).
  • After merge, retroactively fixes the existing `taste-in-software.md` link in Add note: Growing as an engineer in the AI era #8.

@herohua herohua merged commit 4b863da into main May 28, 2026
@herohua herohua deleted the fix-publish-rewrite-note-links branch May 28, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant