Local metadata link commit at 2025-06-06 15:40:57 — file:///home/mrhavens/git-local-repos/git-sigil.git

This commit is contained in:
Mark Randall Havens 2025-06-06 15:40:57 -05:00
commit b548318725
134 changed files with 15789 additions and 0 deletions

View file

@ -0,0 +1,32 @@
---
export const prerender = true;
import DefaultPageLayout from '$/layouts/default.astro'
import PostDraftPreviewList from '$/components/PostDraftPreviewList.astro'
import Paginator from '$/components/Paginator.astro'
import { SITE, PAGE_SIZE } from '$/config'
let title = 'Drafts'
let description = 'You\'re viewing a list of unpublished articles on the site. Accuracy or correctness isn\'t guranteed...'
export async function getStaticPaths({ paginate, rss }) {
let allPosts = []
try {
allPosts = await Astro.glob('../../drafts/*.md');
} catch(error) {
console.log('No draft posts found while generating the index page for the draft pages')
}
const sortedPosts = allPosts.sort((a, b) => new Date(b.date) - new Date(a.date));
return paginate(sortedPosts, {
pageSize: PAGE_SIZE
})
}
const { page } = Astro.props
---
<DefaultPageLayout content={{ title, description }}>
{
(SITE.listDrafts) ? <PostDraftPreviewList posts={page.data} /> : (<p class="text-gray-700 dark:text-gray-100">Looks like you have landed on a unpublished posts page. Please find all the published posts <a href="/blog">here</a>!</p>)
}
<Paginator page={page} />
</DefaultPageLayout>

View file

@ -0,0 +1,47 @@
---
export const prerender = true;
import { getSlugFromPathname } from '$/utils'
export async function getStaticPaths({ }) {
let allPosts = []
try {
allPosts = await Astro.glob('../../../drafts/*.md')
} catch(error) {
console.log('No draft posts found while generating the draft pages')
}
const allSlugs = new Set()
const allPostsWithSlug = allPosts.map(post => {
// @ts-ignore
const slug = getSlugFromPathname(post.file)
allSlugs.add(slug.toLowerCase())
return {
...post,
slug
}
})
return Array.from(allSlugs).map((slug) => {
const filteredPosts = allPostsWithSlug.filter((post) => post.slug === slug )
return {
params: { slug },
props: {
pages: filteredPosts
}
};
});
}
const { slug } = Astro.params
const { pages } = Astro.props
const [ post ] = pages
---
<div class="draft-message">
You're viewing a <strong>preview</strong> of <code>/blog/{slug}</code> which isn't published yet!
</div>
<post.Content/>
<style>
.draft-message {
@apply w-full bg-yellow-300 dark:bg-yellow-700 text-gray-700 dark:text-white px-2 py-1 text-center
}
</style>