Skip to content

feat: enhance internal link localization for blog posts and standard pages - #381

Open
danielmarv wants to merge 1 commit into
mainfrom
Daniel-part
Open

feat: enhance internal link localization for blog posts and standard pages#381
danielmarv wants to merge 1 commit into
mainfrom
Daniel-part

Conversation

@danielmarv

@danielmarv danielmarv commented Jul 31, 2026

Copy link
Copy Markdown
Member

This pull request introduces a locale-aware system for internal links in markdown-rendered content. Authors now write internal links without a locale prefix, and the renderer automatically adds the correct locale prefix based on the current page's locale. This ensures that links resolve correctly for both English and German content, prevents double-prefixing, and leaves external links, anchors, and asset paths unchanged.

Locale-aware internal link handling:

  • Added the localizeInternalLinks function in src/lib/markdown.ts to rewrite locale-neutral internal links so they resolve within the rendered locale, using the correct /de/ or /en/ prefix as needed.
  • Updated the markdown processing pipeline to apply localizeInternalLinks after HTML conversion, ensuring all internal links in page content are correctly localized (getPostBySlug in src/lib/markdown.ts, src/lib/markdown.tsR787-R790; loadPageData in src/app/[locale]/[...rest]/page.tsx, src/app/[locale]/[...rest]/page.tsxL98-R99; import added, src/app/[locale]/[...rest]/page.tsxR9)

Documentation updates:

  • Updated internal link rules in docs/04-adding-blog-post.md to instruct authors to write locale-neutral internal links and describe the new automatic locale prefixing behavior.

Supporting constants and patterns:

  • Added constants for default locale, supported locale prefixes, and asset path detection in src/lib/markdown.ts to support the new link rewriting logic.

…pages

Signed-off-by: Ntege Daniel <danientege785@gmail.com>
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for open-elements ready!

Name Link
🔨 Latest commit 530d7df
🔍 Latest deploy log https://app.netlify.com/projects/open-elements/deploys/6a6cd4a721e6ba0008581f6a
😎 Deploy Preview https://deploy-preview-381--open-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 67
Accessibility: 98
Best Practices: 92
SEO: 100
PWA: 60
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@danielmarv danielmarv changed the title feat: enhance internal link localization for blog posts and standard … feat: enhance internal link localization for blog posts and standard pages Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant