sundays/src/pages/notes/[...id].astro

90 lines
No EOL
4.5 KiB
Text

---
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}` image=`${urlfrag(base, note.data.post_image)}`>
{meta && <script type="application/ld+json" is:inline set:html={meta} />}
<script>
import { bindModals } from '../../utils/modal.js';
bindModals();
</script>
<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>
<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>
<dialog data-scripture=""
class="p-0 rounded-sm w-full lg:max-w-lg xl:max-w-lg 2xl:max-w-lg m-auto flex-col flex hidden scripture">
<div tabindex="-1" autofocus class="p-4">
<button data-close="">
<span class="align-middle">close</span>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle inline" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708"/>
</svg>
</button>
<div class="spinner">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-book-fill hidden" viewBox="0 0 16 16">
<path d="M8 1.783C7.015.936 5.587.81 4.287.94c-1.514.153-3.042.672-3.994 1.105A.5.5 0 0 0 0 2.5v11a.5.5 0 0 0 .707.455c.882-.4 2.303-.881 3.68-1.02 1.409-.142 2.59.087 3.223.877a.5.5 0 0 0 .78 0c.633-.79 1.814-1.019 3.222-.877 1.378.139 2.8.62 3.681 1.02A.5.5 0 0 0 16 13.5v-11a.5.5 0 0 0-.293-.455c-.952-.433-2.48-.952-3.994-1.105C10.413.809 8.985.936 8 1.783"/>
</svg>
</div>
<article class="mt-6">
</article>
<nav>
<a href="#" class="bg">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-link-45deg inline" viewBox="0 0 16 16">
<path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1 1 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4 4 0 0 1-.128-1.287z"/>
<path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243z"/>
</svg>
<span class="align-middle">Open <span class="scripture underline"></span> on Bible Gateway</span>
</a>
</nav>
</div>
</dialog>
</article>
</Layout>