Skip to content

feat(seo): slugs keep native letters, and Unicode atlas routes are encoded exactly once - #341

Merged
Ardnived merged 8 commits into
mainfrom
feat/native-letter-slugs
Nov 25, 2026
Merged

Ardnived merged 8 commits into
mainfrom
feat/native-letter-slugs

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • slugify (heading and tab anchors) now uses the cross-repo recipe and keeps native letters in every script, so #café-société and #über-uns now match SahajCloud's stored anchors.
  • /map atlas routes with Unicode place slugs are decoded once, sent to SahajCloud encoded once, and every emitted URL (canonical, hreflang, sitemap <loc>) is percent-encoded.
  • The [slug] route's own gate accepts those letters too, so a page slugged über-uns has an address at all.
  • Goes with feat(slugs)!: keep native letters in slugs, in every script SahajCloud#1269. Merge this after that PR.

Change outline

Behaviour — slugify

 lib/urls/slugify.ts
-  fold Latin to ASCII (é → e, ß splits), keep other scripts
+  NFC → lowercase → drop apostrophes, Armenian in-word marks, emoji variation/keycap marks
+  → runs of non-\p{L}\p{M}\p{N} → '-' → trim         # the same recipe as SahajCloud and the app

Gate — a content slug

 server/validation.ts               # what slugSchema refuses, `pages/[slug]/+data.ts` 404s
-  slugSchema  /^[a-z0-9]+(?:-[a-z0-9]+)*$/
+  slugSchema  \p{Ll}\p{Lm}\p{Lo}\p{M}\p{N} runs, single-hyphen-joined
+              # SahajCloud's own `slugPattern`, so it accepts whatever slugify emits

Flow — a Unicode /map route

 lib/atlas/route.ts
+  canonicalAtlasRoute(path)        # decode each segment, NFC — called at the boundary only
   matchMapRoute → canonicalAtlasRoute
 server/sahajcloud/atlas.ts
   getAtlasSeo(route) → one encodeURIComponent for ?route=, no second decode
 lib/urls/urls.ts
+  encodeUrl(url)                   # encodes non-printable-ASCII only; leaves %XX ? # & alone
   localeUrl / absoluteHref → encodeUrl
 lib/atlas/seo.ts                   canonical + alternates → encodeUrl

Flow — a sitemap URL

 server/routes/sitemap.xml/route.ts     content <loc> → localeUrl
 server/sahajcloud/atlas.ts             atlas <loc> → encodeUrl, at the upstream boundary
 server/routes/sitemap.xml/sitemap.ts   respells nothing, and dedupes one spelling

Preview

The branch alias tracks the branch's latest successful build, so it answers for whichever commit built last.

/sitemap.xml cannot be reviewed on a preview: isCanonicalOrigin refuses a preview host and the route serves an empty <urlset> there on purpose, so the sitemap half rests on route.test.ts.

Test results

  • Lean gate (check.sh): ✓ — lint, format, tsc --noEmit, 1793 tests in 173 files.
  • New tests: lib/atlas/route.test.ts, embed.test.ts, seo.test.ts, lib/urls/urls.test.ts, sitemap.test.ts and server/sahajcloud/atlas.test.ts, each run with /bg/софия and /de/trier/universität-trier/1998, raw and encoded.
  • server/validation.test.ts asserts the gate accepts every slug slugify emits, over seven scripts; pages/[slug]/route.test.ts and data.test.ts carry /über-uns end to end.

Notes for reviewer

  • Latin heading anchors change (#cafe-societe becomes #café-société). The site is unpublished, so no shared links depend on them.
  • The ?route= encoding against SahajCloud's /api/atlas/seo is unverified live, because local atlas reads return 403. SahajCloud's atlasRoute.ts already decodes each segment.
  • encodeUrl stays a replace rather than new URL(url).href: lib/atlas/seo.ts hands it an upstream canonical, and new URL throws on a malformed one and resolves ...

🤖 Generated with Claude Code

Ardnived and others added 2 commits November 25, 2026 11:16
…coded exactly once

slugify now follows the recipe shared with SahajCloud and WeMeditateApp
(NFC, lowercase, apostrophes dropped, any letter, mark or digit kept), so
heading anchors read "café-société" rather than "cafe-societe".

Vike hands a route over decoded while SahajCloud's webUrl is encoded, so
the /map route is now decoded to one NFC spelling before it reaches the
/api/atlas/seo read and the widget's atlas= parameter, and every URL that
leaves in HTML or XML (canonical, hreflang, sitemap loc) is percent-encoded
by encodeUrl, which is idempotent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 18:38Z address-review · attempt 1 · session · done
  • 18:38Z address-review · attempt 1 · session
  • 18:25Z review-pr · attempt 1 · session · done
  • 18:25Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 25, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The cross-repo claim checks out: this slugify is character-for-character SahajCloud's slugifyValue on feat/umlaut-slugs, vectors too. The diff is no bigger than the problem: 151 lines deleted for 298 added, most of them tests. Two layering problems remain, both about where the one encode lives.

The gap is content slugs, not atlas routes. SahajCloud#1269 makes every slugField keep native letters, so a page slug becomes über-uns too — yet the Summary covers anchors and /map only. pages/[slug]/+route.ts:38 hands match[1] to the slug query undecoded, and only the atlas got a decode. It all rests on "Vike hands the pathname over decoded" (lib/atlas/route.ts:93), which nothing here pins. Add a Unicode content-route case, or say why the claim holds.

Findings

  • should-fix — server/sahajcloud/atlas.ts:75: canonicalized twice, and not idempotent on a segment still holding a % escape.
  • should-fix — server/routes/sitemap.xml/sitemap.ts:68: the alternates encode is dead; the loc encode compensates for a producer.
  • consider — lib/urls/urls.ts:186: new URL(url).href is idempotent on %XX too.
  • consider — lib/urls/slugify.ts:9: the lexical-helpers re-export has one caller.

What was checked

Read whole on the branch: the six changed source files, plus lib/seo/{content-seo,hreflang}.ts and pages/{[slug]/+route,map/+data}.ts. Producer side on SahajCloud feat/umlaut-slugs: slugify.ts, its spec, and atlas-url-contract.json — v2's slugPattern accepts these slugs, and this repo commits no copy.

Every URL emitter traced to localeUrl/absoluteHref. Ran the double-canonicalize in node.

Ladder: 3 pieces, 2 kept. Streamliner: 3 findings, 2 posted — its parseAtlasRoute merge is dropped, since route.ts is a declared port. No ## Preview link, no question threads.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread server/sahajcloud/atlas.ts Resolved
Comment thread server/routes/sitemap.xml/sitemap.ts Resolved
Comment thread lib/urls/urls.ts Resolved
Comment thread lib/urls/slugify.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 25, 2026
`getAtlasSeo` canonicalized the route its caller had already canonicalized
through `matchMapRoute`. The second pass is not a no-op: a segment spelling
a literal escape decodes again, so `/bg/%25D1%2581` asked upstream for `с`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXVGNzZvoNJyFV5xQP
The builder encoded every loc because the content read glued `${origin}/${slug}`
itself, and encoded every alternate for nothing: they already come from
`localeUrl`. The content read now uses `localeUrl` too, the atlas read holds
the spelling for the hand-mirrored upstream field, and the builder respells
nothing.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXVGNzZvoNJyFV5xQP
`lexical-helpers` re-exported it for importers that no longer exist. Its one
caller reads it from `lib/urls/slugify` directly.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXVGNzZvoNJyFV5xQP
`slugSchema` took ASCII only, and a refusal is `render(404)`, so a page whose
slug keeps its native letters had no address at all. The class is now
SahajCloud's own `slugPattern`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXVGNzZvoNJyFV5xQP
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-design 3285ca2 Commit Preview URL

Branch Preview URL
Nov 25 2026, 07:01 PM

@Ardnived
Ardnived enabled auto-merge November 25, 2026 18:51
@sydevs-bot

Copy link
Copy Markdown
Contributor

Four threads answered. The review's gap was a 404.

Adopted — the double canonicalize, the sitemap's two encodes, the lexical-helpers re-export.

Rebutted — new URL(url).href: lib/atlas/seo.ts hands encodeUrl an upstream canonical, and new URL throws on a malformed one. Took the line.

The gap is content slugs, not atlas routes.

slugSchema took [a-z0-9-] only, and a refusal is render(404), so /über-uns had no address. 823de8c widens it to SahajCloud's slugPattern, with a native-letter case at the gate, the matcher and the data hook. decodePathname is named as what decodes.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 25, 2026

@sydevs-dispatcher sydevs-dispatcher Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. 🤖 Written by the sydevs autonomous loop — see what this is

@Ardnived
Ardnived added this pull request to the merge queue Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 25, 2026
Merged via the queue into main with commit e7ae48a Nov 25, 2026
20 checks passed
@Ardnived
Ardnived deleted the feat/native-letter-slugs branch November 25, 2026 19:04
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 25, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 25, 2026
#341 moved `slugify` out of `lexical-helpers` into `lib/urls/slugify`, and
this branch added `IMAGE_CREDIT_CLASS` to the same import. The list keeps
both: the credit class from here, the slug module from main.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWoXwc2UgVbP35ujsy
sydevs-bot pushed a commit that referenced this pull request Nov 25, 2026
Both conflicts were import lines where main reached this branch's own
conclusion by another route.

RichText.tsx: #341 added `import { slugify } from '@/lib/urls/slugify'`,
which 6d39ecc had already added higher up. Kept this branch's import
block, dropped the duplicate.

lexical-helpers.ts: #341 deleted the `slugify` re-export, which 6d39ecc
had also deleted. Kept this branch's `Image`/`Page` type import.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW3VocbMjDB2WnN81x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants