fixed null pointer
This commit is contained in:
@@ -31,6 +31,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatSlug(slug: string) {
|
function formatSlug(slug: string) {
|
||||||
|
if (!slug) return '';
|
||||||
return slug
|
return slug
|
||||||
.split('-')
|
.split('-')
|
||||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||||
@@ -46,9 +47,19 @@ function formatSlug(slug: string) {
|
|||||||
Back to list
|
Back to list
|
||||||
</a>
|
</a>
|
||||||
{post && (
|
{post && (
|
||||||
<h1 class="text-5xl font-extrabold text-mauve mt-4">
|
<div class="flex justify-between items-start mt-4">
|
||||||
|
<h1 class="text-5xl font-extrabold text-mauve">
|
||||||
{formatSlug(post.slug)}
|
{formatSlug(post.slug)}
|
||||||
</h1>
|
</h1>
|
||||||
|
<a
|
||||||
|
href={`/admin/editor?edit=${post.slug}`}
|
||||||
|
id="edit-btn"
|
||||||
|
class="hidden bg-surface0 hover:bg-surface1 text-blue px-4 py-2 rounded border border-surface1 transition-colors items-center gap-2"
|
||||||
|
>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><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>
|
||||||
|
Edit
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -73,22 +84,3 @@ function formatSlug(slug: string) {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</Layout>
|
</Layout>
|
||||||
1.5-5.5Z"/><path d="m15 5 4 4"/></svg>
|
|
||||||
Edit
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</header>
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<div class="text-red text-center py-12">
|
|
||||||
<h2 class="text-2xl font-bold mb-4">{error}</h2>
|
|
||||||
<a href="/" class="text-blue underline">Return home</a>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{post && (
|
|
||||||
<div class="prose prose-invert max-w-none" set:html={html} />
|
|
||||||
)}
|
|
||||||
</article>
|
|
||||||
</Layout>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user