figure out how everything works again

This commit is contained in:
Joseph Montanaro 2022-05-11 20:41:23 -07:00
parent 8c6e39c6e6
commit 8d51cab348
8 changed files with 31 additions and 41 deletions

View File

@ -1,10 +1,11 @@
{ {
"compilerOptions": { "extends": "./.svelte-kit/tsconfig.json",
"baseUrl": ".", "compilerOptions": {
"paths": { "baseUrl": ".",
"$lib": ["src/lib"], "paths": {
"$lib/*": ["src/lib/*"] "$lib": ["src/lib"],
} "$lib/*": ["src/lib/*"]
}, }
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] },
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
} }

View File

@ -1,7 +1,7 @@
<script context="module"> <script context="module">
export async function load({ page }) { export async function load({ url, params }) {
try { try {
let post = await import(`./_posts/${page.params.slug}.svx`); let post = await import(`./_posts/${params.slug}.svx`);
return { return {
props: { props: {
post: post.default post: post.default
@ -9,9 +9,10 @@
} }
} }
catch (err) { catch (err) {
console.log(err);
return { return {
status: 404, status: 404,
error: `Not found: ${page.path}`, error: `Not found: ${url.pathname}`,
} }
} }
} }

View File

@ -1,6 +1,4 @@
<style> <style>
:global(main) { :global(main) {
--content-width: 42rem; --content-width: 42rem;
box-sizing: border-box; box-sizing: border-box;

View File

@ -1,8 +1,8 @@
<script context="module"> <script context="module">
export async function load({ fetch }) { export async function load({ fetch }) {
const resp = await fetch('/latest.json'); const resp = await fetch('/latest.json');
const metadata = await resp.json(); const postMeta = await resp.json();
const post = await import(`./_posts/${metadata.slug}.svx`); const post = await import(`./_posts/${postMeta.slug}.svx`);
return { return {
props: { props: {
post: post.default, post: post.default,

View File

@ -1,4 +1,4 @@
import { postData } from './all.json.js'; import { postData } from './posts.js';
export async function get() { export async function get() {
return {body: postData[0]}; return {body: postData[0]};

View File

@ -15,6 +15,8 @@ postData.sort((a, b) => {
}) })
export async function get() { export async function get() {
return {body: postData}; return {
body: {postData}
};
} }

View File

@ -1,14 +1,3 @@
<script context="module">
export async function load({ page, fetch }) {
const resp = await fetch('/all.json');
return {
props: {
postData: await resp.json()
}
}
}
</script>
<script> <script>
export let postData; export let postData;
</script> </script>

View File

@ -5,19 +5,18 @@ import slug from './src/lib/slug.js';
const config = { const config = {
extensions: ['.svelte', '.svx'], extensions: ['.svelte', '.svx'],
preprocess: [ preprocess: [
mdsvex({ mdsvex({
layout: './src/lib/Post.svelte', layout: './src/lib/Post.svelte',
rehypePlugins: [slug], rehypePlugins: [slug],
}), }),
svp.scss(), svp.scss(),
], ],
kit: { kit: {
// hydrate the <div id="svelte"> element in src/app.html // hydrate the <div id="svelte"> element in src/app.html
target: '#svelte', adapter: staticAdapter(),
adapter: staticAdapter(), }
}
}; };
export default config; export default config;