fixed invalid post title breaking links

This commit is contained in:
2026-05-09 05:59:56 +02:00
parent bd18b96846
commit 801df057e0
6 changed files with 23 additions and 16 deletions
+2 -2
View File
@@ -24,7 +24,7 @@ let html = '';
let error = '';
try {
const response = await fetch(`${API_URL}/api/posts/${slug}`);
const response = await fetch(`${API_URL}/api/posts/${encodeURIComponent(slug ?? '')}`);
if (response.ok) {
post = await response.json();
html = renderMarkdown(post!.content);
@@ -98,7 +98,7 @@ const isAdmin = Astro.cookies.get('admin_session')?.value === '1';
</div>
<a
id="edit-link"
href={`/admin/editor?edit=${post.slug}`}
href={`/admin/editor?edit=${encodeURIComponent(post.slug)}`}
class={`bg-surface0 hover:bg-surface1 text-blue px-3 py-1.5 md:px-4 md:py-2 rounded border border-surface1 transition-colors inline-flex items-center gap-2 text-sm md:text-base self-start ${isAdmin ? '' : 'hidden'}`}
>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="md:w-4 md:h-4"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>