feat: pretty post URLs /p/<code>/<title-slug> in single-community mode
The code is the post id through a reversible 32-bit mix in base36: unique, short, and not the raw sequential id. Only the code resolves the post (via the reroute hook), so the slug can change with the title. Feed links, the share button, canonical and og:url use the pretty form, and old /post/<instance>/<id> links are rewritten in the address bar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011c5BZVwWdVLrdQi9htmuth
This commit is contained in:
1 parent
302700ef66
commit
8e7c5be4c8
6 files changed
+109
-4
No files matched your search
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" module>
|
||||
import { SINGLE_COMMUNITY } from '$lib/app/single'
|
||||
import { prettyPostPath, prettyPostUrls } from '$lib/app/slug'
|
||||
import type { Community, Person, SubscribedType } from '$lib/api/types'
|
||||
import { profile } from '$lib/app/auth'
|
||||
import { t } from '$lib/app/i18n'
|
||||
@@ -371,7 +372,9 @@
|
||||
<a
|
||||
href={useAttachedUrl
|
||||
? postUrl
|
||||
: `/post/${encodeURIComponent(profile.current.instance)}/${id}`}
|
||||
: prettyPostUrls
|
||||
? prettyPostPath(id, title)
|
||||
: `/post/${encodeURIComponent(profile.current.instance)}/${id}`}
|
||||
target={useAttachedUrl ? '_blank' : undefined}
|
||||
rel={useAttachedUrl ? 'noopener noreferrer' : undefined}
|
||||
class="inline-block hover:underline hover:text-primary-900 dark:hover:text-primary-100 transition-colors"
|
||||
|
||||
Reference in new issue
Block a user