Rewrite internal links in book page content to hero_books context #29

Closed
opened 2026-02-09 14:52:25 +00:00 by mik-tf · 0 comments
Owner

Current Behavior

Image URLs in page content are rewritten to serve correctly via rewrite_image_urls() in server.rs. However, hyperlinks in markdown content pass through as-is — they still point to the original source repository locations (e.g., relative paths like ../other-page or absolute git URLs).

Expected Behavior

All internal links in rendered page content should be rewritten to navigate within hero_books. For example:

  • A relative link ../networking/setup.md in a mycelium book should become /book/mycelium_networking/page/setup
  • Links to other pages within the same book should resolve correctly
  • External links (https://...) should be left unchanged

Location

  • src/web/server.rsrewrite_image_urls() function (lines ~3788-3824) handles images; a similar rewrite_content_links() is needed for <a href> tags
  • templates/page.html line 111 — {{ content_html|safe }} renders the content

Complexity

Medium-high. Requires mapping source repo directory structures to hero_books page URL patterns.

## Current Behavior Image URLs in page content are rewritten to serve correctly via `rewrite_image_urls()` in `server.rs`. However, **hyperlinks** in markdown content pass through as-is — they still point to the original source repository locations (e.g., relative paths like `../other-page` or absolute git URLs). ## Expected Behavior All internal links in rendered page content should be rewritten to navigate within hero_books. For example: - A relative link `../networking/setup.md` in a mycelium book should become `/book/mycelium_networking/page/setup` - Links to other pages within the same book should resolve correctly - External links (https://...) should be left unchanged ## Location - `src/web/server.rs` — `rewrite_image_urls()` function (lines ~3788-3824) handles images; a similar `rewrite_content_links()` is needed for `<a href>` tags - `templates/page.html` line 111 — `{{ content_html|safe }}` renders the content ## Complexity Medium-high. Requires mapping source repo directory structures to hero_books page URL patterns.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_books#29
No description provided.