first commit
This commit is contained in:
40
templates/starter-cloudflare/src/pages/[slug].astro
Normal file
40
templates/starter-cloudflare/src/pages/[slug].astro
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
import { getEmDashEntry, getSeoMeta } from "emdash";
|
||||
import { PortableText } from "emdash/ui";
|
||||
import Base from "../layouts/Base.astro";
|
||||
|
||||
const { slug } = Astro.params;
|
||||
|
||||
if (!slug) {
|
||||
return Astro.redirect("/404");
|
||||
}
|
||||
|
||||
const { entry: page, cacheHint } = await getEmDashEntry("pages", slug);
|
||||
|
||||
if (!page) {
|
||||
return Astro.redirect("/404");
|
||||
}
|
||||
|
||||
Astro.cache.set(cacheHint);
|
||||
|
||||
const seo = getSeoMeta(page, {
|
||||
siteTitle: "My Site",
|
||||
siteUrl: Astro.url.origin,
|
||||
path: `/${slug}`,
|
||||
});
|
||||
---
|
||||
|
||||
<Base
|
||||
title={seo.title}
|
||||
description={seo.description}
|
||||
canonical={seo.canonical}
|
||||
content={{ collection: "pages", id: page.data.id, slug }}
|
||||
>
|
||||
<article>
|
||||
<h1 {...page.edit.title}>{page.data.title}</h1>
|
||||
|
||||
<div {...page.edit.content}>
|
||||
<PortableText value={page.data.content} />
|
||||
</div>
|
||||
</article>
|
||||
</Base>
|
||||
Reference in New Issue
Block a user