Przymiarka do dokumentów
This commit is contained in:
32
src/pages/dokumenty/[slug].astro
Normal file
32
src/pages/dokumenty/[slug].astro
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
import DefaultLayout from "../../layouts/DefaultLayout.astro";
|
||||
import Markdown from "../../islands/Markdown.jsx";
|
||||
import { marked } from "marked";
|
||||
import { getDocumentBySlug } from "../../lib/documents";
|
||||
|
||||
const { slug } = Astro.params;
|
||||
|
||||
const doc = slug ? getDocumentBySlug(slug) : null;
|
||||
if (!doc || doc.visible !== true) {
|
||||
return Astro.redirect("/dokumenty", 302);
|
||||
}
|
||||
|
||||
const html = marked.parse(doc.content);
|
||||
---
|
||||
|
||||
<DefaultLayout title={doc.title}>
|
||||
<section class="max-w-4xl mx-auto px-4 py-10">
|
||||
<a href="/dokumenty" class="text-sm opacity-70 hover:opacity-100">
|
||||
← Wróć do dokumentów
|
||||
</a>
|
||||
|
||||
<h1 class="mt-4 text-4xl md:text-5xl font-bold text-[--f-header]">
|
||||
{doc.title}
|
||||
</h1>
|
||||
|
||||
<article class="mt-8 prose max-w-none">
|
||||
<Markdown text={html} />
|
||||
<!-- <div set:html={html} /> -->
|
||||
</article>
|
||||
</section>
|
||||
</DefaultLayout>
|
||||
Reference in New Issue
Block a user