feat: Customizable content in `content/`
This commit is contained in:
parent
86c9718c22
commit
a232ce2361
|
@ -25,6 +25,7 @@
|
|||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.36.0",
|
||||
"globals": "^15.0.0",
|
||||
"mdsvex": "^0.12.3",
|
||||
"prettier": "^3.1.1",
|
||||
"prettier-plugin-svelte": "^3.1.2",
|
||||
"prettier-plugin-tailwindcss": "^0.6.5",
|
||||
|
@ -1120,6 +1121,13 @@
|
|||
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/unist": {
|
||||
"version": "2.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz",
|
||||
"integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.5.0.tgz",
|
||||
|
@ -2895,6 +2903,22 @@
|
|||
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz",
|
||||
"integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA=="
|
||||
},
|
||||
"node_modules/mdsvex": {
|
||||
"version": "0.12.3",
|
||||
"resolved": "https://registry.npmjs.org/mdsvex/-/mdsvex-0.12.3.tgz",
|
||||
"integrity": "sha512-C/uIJamjNo5PHHnR3JHqsBPoLcfUBpzRmAEB6FLMXI/s7XHOceswjDMKqSPEW2WHmYpKm0taZ3U20GSyhMridA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/unist": "^2.0.3",
|
||||
"prism-svelte": "^0.4.7",
|
||||
"prismjs": "^1.17.1",
|
||||
"vfile-message": "^2.0.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^3.56.0 || ^4.0.0 || ^5.0.0-next.120"
|
||||
}
|
||||
},
|
||||
"node_modules/merge-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
|
||||
|
@ -3592,6 +3616,23 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/prism-svelte": {
|
||||
"version": "0.4.7",
|
||||
"resolved": "https://registry.npmjs.org/prism-svelte/-/prism-svelte-0.4.7.tgz",
|
||||
"integrity": "sha512-yABh19CYbM24V7aS7TuPYRNMqthxwbvx6FF/Rw920YbyBWO3tnyPIqRMgHuSVsLmuHkkBS1Akyof463FVdkeDQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.29.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",
|
||||
"integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/punycode": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||
|
@ -4409,6 +4450,20 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/unist-util-stringify-position": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz",
|
||||
"integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/unist": "^2.0.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/update-browserslist-db": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz",
|
||||
|
@ -4453,6 +4508,21 @@
|
|||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||
},
|
||||
"node_modules/vfile-message": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz",
|
||||
"integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/unist": "^2.0.0",
|
||||
"unist-util-stringify-position": "^2.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.4.4",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.4.tgz",
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.36.0",
|
||||
"globals": "^15.0.0",
|
||||
"mdsvex": "^0.12.3",
|
||||
"prettier": "^3.1.1",
|
||||
"prettier-plugin-svelte": "^3.1.2",
|
||||
"prettier-plugin-tailwindcss": "^0.6.5",
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
name: Cirno
|
||||
---
|
||||
# Biography
|
||||
|
||||
Strongest of Gensokyo
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
title: Placeholder 1
|
||||
date: '2024-09-01'
|
||||
---
|
||||
# Placeholder Post 1
|
||||
|
||||
Here is some placeholder text
|
|
@ -10,6 +10,10 @@
|
|||
progress = Math.min(1, scrollPosition / scrollHeight);
|
||||
}
|
||||
}
|
||||
|
||||
import type { PageData } from './$types';
|
||||
export let data: PageData;
|
||||
const { name, Content } = data;
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
@ -38,11 +42,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="bio" class="bg-white dark:bg-gray-900" style="">
|
||||
<h1>Home Page</h1>
|
||||
<p>This is the home page. You have scrolled {scrollPosition} / {scrollHeight}, progress: {progress}</p>
|
||||
<h2>{name}</h2>
|
||||
<Content />
|
||||
</div>
|
||||
|
||||
|
||||
<svelte:window
|
||||
bind:scrollY={scrollPosition}
|
||||
bind:innerHeight={scrollHeight}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import { error } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const post = await import(`$content/home.md`);
|
||||
if (!post) throw error(404);
|
||||
const { name, date } = post.metadata;
|
||||
const Content = post.default;
|
||||
|
||||
return {
|
||||
name,
|
||||
Content,
|
||||
};
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
# Archives
|
|
@ -1,12 +0,0 @@
|
|||
import { error } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
const post = params.slug;
|
||||
|
||||
if (!post) throw error(404);
|
||||
|
||||
return {
|
||||
post
|
||||
};
|
||||
}
|
|
@ -1,6 +1,11 @@
|
|||
<script lang="ts">
|
||||
export let data: string;
|
||||
import type { PageData } from './$types';
|
||||
export let data: PageData;
|
||||
const { title, date, Content } = data;
|
||||
</script>
|
||||
|
||||
|
||||
<h1>Blog {data.post}</h1>
|
||||
<article>
|
||||
<h1>{title}</h1>
|
||||
<p>Published: {date}</p>
|
||||
<Content />
|
||||
</article>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import { error } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
try {
|
||||
const post = await import(`$content/post/${params.slug}.md`);
|
||||
if (!post) throw error(404);
|
||||
const { title, date } = post.metadata;
|
||||
const Content = post.default;
|
||||
|
||||
return {
|
||||
Content,
|
||||
title,
|
||||
date
|
||||
};
|
||||
}
|
||||
catch(_e) {
|
||||
throw error(404)
|
||||
}
|
||||
}
|
|
@ -1,11 +1,16 @@
|
|||
import adapter from '@sveltejs/adapter-auto';
|
||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
import { mdsvex } from 'mdsvex';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
||||
// for more information about preprocessors
|
||||
preprocess: vitePreprocess(),
|
||||
preprocess: [
|
||||
vitePreprocess(),
|
||||
mdsvex({ extensions: ['.md'] })
|
||||
],
|
||||
extensions: [".svelte", ".md"],
|
||||
|
||||
kit: {
|
||||
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
||||
|
@ -13,7 +18,8 @@ const config = {
|
|||
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
|
||||
adapter: adapter(),
|
||||
alias: {
|
||||
"@/*": "./path/to/lib/*",
|
||||
$content: "src/content",
|
||||
"@/*": "./*",
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler"
|
||||
"moduleResolution": "bundler",
|
||||
"lib": ["es2015"]
|
||||
}
|
||||
// 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
|
||||
|
|
Loading…
Reference in New Issue