Renamed slug.
This commit is contained in:
parent
2e098f7585
commit
c83e38c868
1 changed files with 0 additions and 0 deletions
59
src/pages/notes/[...id].astro
Normal file
59
src/pages/notes/[...id].astro
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
import { getCollection, getEntry, render } from 'astro:content';
|
||||
import { type CollectionEntry } from 'astro:content';
|
||||
import { dateFormat } from '../../utils/date';
|
||||
import { urlfrag } from '../../utils/path';
|
||||
import { titleCase } from '../../utils/strings';
|
||||
|
||||
interface Props {
|
||||
note: CollectionEntry<'notes'>;
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const notes = await getCollection('notes');
|
||||
return notes.map((note: CollectionEntry<'notes'>) => ({
|
||||
params: { id: note.id.replace(/-/, '/') },
|
||||
props: { note },
|
||||
}));
|
||||
}
|
||||
|
||||
const base = import.meta.env.BASE_URL;
|
||||
const { note } = Astro.props;
|
||||
const { Content } = await render(note);
|
||||
|
||||
const meta = `{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BlogPosting",
|
||||
"headline": "${note.data.title}",
|
||||
"image": "${urlfrag(base, note.data.post_image)}",
|
||||
"author": {"@type": "Person", "name": "Benjamin A. Shelton"},
|
||||
"publisher": {"@type": "Organization", "name": "Just Us"},
|
||||
"datePublished": "${note.data.date.toISOString()}",
|
||||
"dateModified": "${note.data.date.toISOString()}"
|
||||
}`;
|
||||
|
||||
---
|
||||
|
||||
<Layout title=`${note.data.title} - ${note.data.sub_heading}`>
|
||||
{meta && <script type="application/ld+json" is:inline set:html={meta} />}
|
||||
<article class="mx-auto p-4 lg:p-0 lg:max-w-6xl xl:p-0 xl:max-w-6xl 2xl:p-0 2xl:max-w-6xl" id="notes-page">
|
||||
<div class="header">
|
||||
<hgroup>
|
||||
<h1 id="title">{note.data.title}</h1>
|
||||
<h2 id="subtitle">{note.data.sub_heading}</h2>
|
||||
</hgroup>
|
||||
<section id="meta">
|
||||
<time>{dateFormat(note.data.date)}</time>
|
||||
<span class="divider">
|
||||
<ul class="tags">
|
||||
{note.data.tags?.filter((tag: string) => (tag != 'notes')).map((tag: string) => (
|
||||
<li>{titleCase(tag)}</li>
|
||||
))}</ul>
|
||||
</section>
|
||||
</div>
|
||||
<div id="content" class="p-6">
|
||||
<Content />
|
||||
</div>
|
||||
</article>
|
||||
</Layout>
|
||||
Loading…
Reference in a new issue