Blog listing
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
import {metadata as htmlInCssMetadata} from "./html-in-css/+page.svx"
|
||||
|
||||
const posts = [
|
||||
{
|
||||
href: '/blog/html-in-css',
|
||||
...htmlInCssMetadata
|
||||
}
|
||||
]
|
||||
|
||||
export const load = async () => {
|
||||
const posts = import.meta.glob("./**/*.svx", {eager: true})
|
||||
const postPaths = Object.keys(posts)
|
||||
|
||||
const pages = await Promise.all(postPaths.map(async (pp) => {
|
||||
const {metadata} = await import(pp)
|
||||
return {
|
||||
path: pp
|
||||
.replace('/+page.svx', '')
|
||||
.replace('.', '/blog'),
|
||||
...metadata
|
||||
}
|
||||
}))
|
||||
|
||||
return {
|
||||
pages
|
||||
posts
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
</script>
|
||||
|
||||
<section class="px-2 md:px-8 mb-16 max-w-[1280px] mx-auto">
|
||||
{#each data.pages as page}
|
||||
<a href={page.path}>
|
||||
<h2 class="text-3xl mb-4 md:text-4xl">{page.title}</h2>
|
||||
{#each data.posts as post}
|
||||
<a href={post.href}>
|
||||
<h2 class="text-3xl mb-4 md:text-4xl">{post.title}</h2>
|
||||
</a>
|
||||
{/each}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user