fixed null pointer
This commit is contained in:
@@ -31,6 +31,7 @@ try {
|
||||
}
|
||||
|
||||
function formatSlug(slug: string) {
|
||||
if (!slug) return '';
|
||||
return slug
|
||||
.split('-')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
@@ -46,9 +47,19 @@ function formatSlug(slug: string) {
|
||||
Back to list
|
||||
</a>
|
||||
{post && (
|
||||
<h1 class="text-5xl font-extrabold text-mauve mt-4">
|
||||
{formatSlug(post.slug)}
|
||||
</h1>
|
||||
<div class="flex justify-between items-start mt-4">
|
||||
<h1 class="text-5xl font-extrabold text-mauve">
|
||||
{formatSlug(post.slug)}
|
||||
</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>
|
||||
|
||||
@@ -73,22 +84,3 @@ function formatSlug(slug: string) {
|
||||
}
|
||||
</script>
|
||||
</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