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,4 +1,5 @@
{ {
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {

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

@ -15,7 +15,6 @@ const config = {
], ],
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(),
} }
}; };