feat: Blog catalog
This commit is contained in:
parent
a232ce2361
commit
c75c8ca514
|
@ -5,7 +5,7 @@
|
||||||
let scrollHeight: number = 1;
|
let scrollHeight: number = 1;
|
||||||
let progress: number = 0;
|
let progress: number = 0;
|
||||||
|
|
||||||
function onScroll(p) {
|
function onScroll(_p) {
|
||||||
if (scrollHeight > 1) {
|
if (scrollHeight > 1) {
|
||||||
progress = Math.min(1, scrollPosition / scrollHeight);
|
progress = Math.min(1, scrollPosition / scrollHeight);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,24 @@
|
||||||
<h1>Blog root</h1>
|
<script lang="ts">
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
export let data: PageData;
|
||||||
|
const { allPosts } = data;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{#each allPosts as post}
|
||||||
|
<li>
|
||||||
|
<div>
|
||||||
|
<h2 style="display: flex">
|
||||||
|
<a id="post-title" href={post.path}>{post.meta.title}</a>
|
||||||
|
</h2>
|
||||||
|
Published {post.meta.date}
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#post-title {
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
|
export const load: PageLoad = async ({ params }) => {
|
||||||
|
const allPostFiles = import.meta.glob('$content/post/*.md');
|
||||||
|
const iterablePostFiles = Object.entries(allPostFiles);
|
||||||
|
|
||||||
|
const allPosts = await Promise.all(
|
||||||
|
iterablePostFiles.map(async ([path, resolver]) => {
|
||||||
|
const { metadata } = await resolver();
|
||||||
|
const postPath = path.slice("/src/content/".length, -".md".length);
|
||||||
|
|
||||||
|
return {
|
||||||
|
meta: metadata,
|
||||||
|
path: postPath
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
allPosts
|
||||||
|
};
|
||||||
|
};
|
|
@ -10,7 +10,7 @@
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"lib": ["es2015"]
|
"lib": ["es2020"]
|
||||||
}
|
}
|
||||||
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
||||||
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
|
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
|
||||||
|
|
Loading…
Reference in New Issue