feat: moved content back into this repository, and moved private content out
This commit is contained in:
parent
7fb4035f31
commit
63a079deb1
14 changed files with 62 additions and 132 deletions
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
import { getCollection, render } from 'astro:content';
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
import { formatDate, formatListItem } from '../../lib/format';
|
||||
import { getSlug, enrichPostWithDates, enrichPostsWithDates, resolveRelatedPosts } from '../../lib/md';
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
import { formatDate, formatListItem } from '../lib/format';
|
||||
import { getSlug, enrichPostWithDates, enrichPostsWithDates, resolveRelatedPosts } from '../lib/md';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const rawPosts = await getCollection('md');
|
||||
|
|
@ -27,7 +27,7 @@ const related = post.data.related ? resolveRelatedPosts(post.data.related, allPo
|
|||
{related.length > 0 && (
|
||||
<details open>
|
||||
<summary>related</summary>
|
||||
<pre set:html={related.map(p => formatListItem(p.dates.created, `/md/${getSlug(p.id)}`, p.data.title)).join('\n')} />
|
||||
<pre set:html={related.map(p => formatListItem(p.dates.created, `/${getSlug(p.id)}`, p.data.title)).join('\n')} />
|
||||
</details>
|
||||
)}
|
||||
</Layout>
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
---
|
||||
export const prerender = false;
|
||||
|
||||
import { getCollection, render } from 'astro:content';
|
||||
import { requireAdminSession } from '../../lib/auth';
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
import { getSlug, resolveRelatedPosts } from '../../lib/dnd';
|
||||
|
||||
const { session, error } = await requireAdminSession(Astro.request);
|
||||
if (error) return error;
|
||||
if (!session) return Astro.redirect('/api/auth/signin');
|
||||
|
||||
const slug = Astro.params.slug;
|
||||
const allPosts = await getCollection('dnd');
|
||||
const post = allPosts.find(p => getSlug(p.id) === slug);
|
||||
|
||||
if (!post) {
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
|
||||
const { Content } = await render(post);
|
||||
const related = post.data.related ? resolveRelatedPosts(post.data.related, allPosts) : [];
|
||||
---
|
||||
<Layout title={`${post.data.title} - lewis m.w.`}>
|
||||
|
||||
<article>
|
||||
<h1>{post.data.title}</h1>
|
||||
<Content />
|
||||
</article>
|
||||
{related.length > 0 && (
|
||||
<details open>
|
||||
<summary>related</summary>
|
||||
<pre set:html={related.map(p =>
|
||||
`<a href="/dnd/${getSlug(p.id)}">${p.data.title}</a>`
|
||||
).join('\n')} />
|
||||
</details>
|
||||
)}
|
||||
</Layout>
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
---
|
||||
export const prerender = false;
|
||||
|
||||
import { getCollection } from 'astro:content';
|
||||
import { requireAdminSession } from '../../lib/auth';
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
import { organizePostsByCategory, getSlug } from '../../lib/dnd';
|
||||
import map from '../../content/dnd/drakkenheim/map.jpg';
|
||||
|
||||
const { session, error } = await requireAdminSession(Astro.request);
|
||||
if (error) return error;
|
||||
if (!session) return Astro.redirect('/api/auth/signin');
|
||||
|
||||
const posts = await getCollection('dnd');
|
||||
const { grouped, categories: sortedCategories } = organizePostsByCategory(posts);
|
||||
---
|
||||
<Layout title="dnd - lewis m.w.">
|
||||
|
||||
<p class="muted">logged in as {session.user?.name} <a href="/api/auth/signout">sign out</a></p>
|
||||
|
||||
<img src={map.src} alt="Drakkenheim map" />
|
||||
|
||||
{sortedCategories.length === 0 ? (
|
||||
<p class="muted">nothing here</p>
|
||||
) : (
|
||||
sortedCategories.map(category => (
|
||||
<details open>
|
||||
<summary>{category}</summary>
|
||||
<pre set:html={grouped[category].map(post =>
|
||||
`<a href="/dnd/${getSlug(post.id)}">${post.data.title}</a>${post.data.pinned ? ' [pinned]' : ''}`
|
||||
).join('\n')} />
|
||||
</details>
|
||||
))
|
||||
)}
|
||||
</Layout>
|
||||
|
|
@ -14,7 +14,7 @@ export async function GET(context: APIContext) {
|
|||
...posts.map(post => ({
|
||||
title: post.data.title,
|
||||
pubDate: post.dates.created,
|
||||
link: `/md/${getSlug(post.id)}`,
|
||||
link: `/${getSlug(post.id)}`,
|
||||
description: post.data.title,
|
||||
})),
|
||||
...txtFiles.map(txt => ({
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ try {
|
|||
<details open>
|
||||
<summary>{category}</summary>
|
||||
<pre set:html={[
|
||||
...categoryPosts.slice(0, 10).map(post => formatListItem(post.dates.created, `/md/${getSlug(post.id)}`, post.data.title, { pinned: post.data.pinned })),
|
||||
...categoryPosts.slice(0, 10).map(post => formatListItem(post.dates.created, `/${getSlug(post.id)}`, post.data.title, { pinned: post.data.pinned })),
|
||||
...(categoryPosts.length > 10 ? [`<a href="/md/">+${categoryPosts.length - 10} more</a>`] : [])
|
||||
].join('\n')} />
|
||||
</details>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const { grouped, categories: sortedCategories } = organizePostsByCategory(posts)
|
|||
{sortedCategories.map(category => (
|
||||
<details open>
|
||||
<summary>{category}</summary>
|
||||
<pre set:html={grouped[category].map(post => formatListItem(post.dates.created, `/md/${getSlug(post.id)}`, post.data.title, { pinned: post.data.pinned })).join('\n')} />
|
||||
<pre set:html={grouped[category].map(post => formatListItem(post.dates.created, `/${getSlug(post.id)}`, post.data.title, { pinned: post.data.pinned })).join('\n')} />
|
||||
</details>
|
||||
))}
|
||||
</Layout>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export async function GET(context: APIContext) {
|
|||
const txtFiles = getTxtFileNames();
|
||||
|
||||
const urls = [
|
||||
...posts.map(post => `/md/${getSlug(post.id)}`),
|
||||
...posts.map(post => `/${getSlug(post.id)}`),
|
||||
...txtFiles.map(txt => `/${txt}`),
|
||||
...bookmarks.map(b => b.data.url),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ export async function GET(context: APIContext) {
|
|||
|
||||
const urls = [
|
||||
'/',
|
||||
'/md',
|
||||
...posts.map(post => `/md/${getSlug(post.id)}`),
|
||||
...posts.map(post => `/${getSlug(post.id)}`),
|
||||
'/txt',
|
||||
...txtFiles.map(txt => `/${txt}`),
|
||||
'/bookmarks',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue