From 1ee94589358afad3f7f3012097a0baddd95771e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9D=95=AF=F0=9D=96=8A=F0=9D=96=92=F0=9D=96=94?= =?UTF-8?q?=F0=9D=96=93?= <78769380+codegod100@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:08:51 -0700 Subject: [PATCH] sveltekit --- .gitignore | 23 +++++++ package.json | 2 + pnpm-lock.yaml | 113 +++++++++++++++++++++++++++++++++ src/App.svelte | 68 -------------------- src/app.d.ts | 13 ++++ index.html => src/app.html | 4 +- src/main.ts | 2 +- src/routes/+layout.svelte | 24 +++++++ src/routes/+layout.ts | 1 + src/routes/+page.svelte | 35 ++++++++++ src/routes/[rkey]/+page.svelte | 43 +++++++++++++ svelte.config.js | 27 ++++++-- tsconfig.json | 37 +++++------ vite.config.ts | 6 +- 14 files changed, 298 insertions(+), 100 deletions(-) delete mode 100644 src/App.svelte create mode 100644 src/app.d.ts rename index.html => src/app.html (83%) create mode 100644 src/routes/+layout.svelte create mode 100644 src/routes/+layout.ts create mode 100644 src/routes/+page.svelte create mode 100644 src/routes/[rkey]/+page.svelte diff --git a/.gitignore b/.gitignore index a547bf3..2df4290 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,26 @@ dist-ssr *.njsproj *.sln *.sw? + + +node_modules + +# Output +.output +.vercel +/.svelte-kit +/build + +# OS +.DS_Store +Thumbs.db + +# Env +.env +.env.* +!.env.example +!.env.test + +# Vite +vite.config.js.timestamp-* +vite.config.ts.timestamp-* diff --git a/package.json b/package.json index 9d2726b..7e686fa 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "check": "svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json" }, "devDependencies": { + "@sveltejs/kit": "^2.0.0", "@sveltejs/vite-plugin-svelte": "^4.0.0", "@tsconfig/svelte": "^5.0.4", "svelte": "^5.0.3", @@ -21,6 +22,7 @@ "dependencies": { "@atcute/client": "^2.0.3", "@atcute/whitewind": "^1.0.2", + "@sveltejs/adapter-static": "^3.0.6", "marked": "^14.1.3", "moment": "^2.30.1" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e825ae7..6bbe788 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@atcute/whitewind': specifier: ^1.0.2 version: 1.0.2(@atcute/client@2.0.3) + '@sveltejs/adapter-static': + specifier: ^3.0.6 + version: 3.0.6(@sveltejs/kit@2.7.3(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.4)(vite@5.4.10))(svelte@5.1.4)(vite@5.4.10)) marked: specifier: ^14.1.3 version: 14.1.3 @@ -21,6 +24,9 @@ importers: specifier: ^2.30.1 version: 2.30.1 devDependencies: + '@sveltejs/kit': + specifier: ^2.0.0 + version: 2.7.3(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.4)(vite@5.4.10))(svelte@5.1.4)(vite@5.4.10) '@sveltejs/vite-plugin-svelte': specifier: ^4.0.0 version: 4.0.0(svelte@5.1.4)(vite@5.4.10) @@ -213,6 +219,9 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + '@polka/url@1.0.0-next.28': + resolution: {integrity: sha512-8LduaNlMZGwdZ6qWrKlfa+2M4gahzFkprZiAt2TF8uS0qQgBizKXpXURqvTJ4WtmupWxaLqjRb2UCTe72mu+Aw==} + '@rollup/rollup-android-arm-eabi@4.24.2': resolution: {integrity: sha512-ufoveNTKDg9t/b7nqI3lwbCG/9IJMhADBNjjz/Jn6LxIZxD7T5L8l2uO/wD99945F1Oo8FvgbbZJRguyk/BdzA==} cpu: [arm] @@ -303,6 +312,20 @@ packages: cpu: [x64] os: [win32] + '@sveltejs/adapter-static@3.0.6': + resolution: {integrity: sha512-MGJcesnJWj7FxDcB/GbrdYD3q24Uk0PIL4QIX149ku+hlJuj//nxUbb0HxUTpjkecWfHjVveSUnUaQWnPRXlpg==} + peerDependencies: + '@sveltejs/kit': ^2.0.0 + + '@sveltejs/kit@2.7.3': + resolution: {integrity: sha512-Vx7nq5MJ86I8qXYsVidC5PX6xm+uxt8DydvOdmJoyOK7LvGP18OFEG359yY+aa51t6pENvqZAMqAREQQx1OI2Q==} + engines: {node: '>=18.13'} + hasBin: true + peerDependencies: + '@sveltejs/vite-plugin-svelte': ^3.0.0 || ^4.0.0-next.1 + svelte: ^4.0.0 || ^5.0.0-next.0 + vite: ^5.0.3 + '@sveltejs/vite-plugin-svelte-inspector@3.0.1': resolution: {integrity: sha512-2CKypmj1sM4GE7HjllT7UKmo4Q6L5xFRd7VMGEWhYnZ+wc6AUVU01IBd7yUi6WnFndEwWoMNOd6e8UjoN0nbvQ==} engines: {node: ^18.0.0 || ^20.0.0 || >=22} @@ -321,6 +344,9 @@ packages: '@tsconfig/svelte@5.0.4': resolution: {integrity: sha512-BV9NplVgLmSi4mwKzD8BD/NQ8erOY/nUE/GpgWe2ckx+wIQF5RyRirn/QsSSCPeulVpc3RA/iJt6DpfTIZps0Q==} + '@types/cookie@0.6.0': + resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} + '@types/estree@1.0.6': resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} @@ -346,6 +372,10 @@ packages: resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==} engines: {node: '>= 14.16.0'} + cookie@0.6.0: + resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} + engines: {node: '>= 0.6'} + debug@4.3.7: resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==} engines: {node: '>=6.0'} @@ -359,6 +389,9 @@ packages: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} + devalue@5.1.1: + resolution: {integrity: sha512-maua5KUiapvEwiEAe+XnlZ3Rh0GD+qI1J/nb9vrJc3muPXvcF/8gXYTWF76+5DAqHyDUtOIImEuo0YKE9mshVw==} + esbuild@0.21.5: resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==} engines: {node: '>=12'} @@ -383,6 +416,15 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] + globalyzer@0.1.0: + resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==} + + globrex@0.1.2: + resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} + + import-meta-resolve@4.1.0: + resolution: {integrity: sha512-I6fiaX09Xivtk+THaMfAwnA3MVA5Big1WHF1Dfx9hFuvNIWpXnorlkzhcQf6ehrqQiiZECRt1poOAkPmer3ruw==} + is-reference@3.0.2: resolution: {integrity: sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==} @@ -408,6 +450,10 @@ packages: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} + mrmime@2.0.0: + resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==} + engines: {node: '>=10'} + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -436,6 +482,13 @@ packages: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} + set-cookie-parser@2.7.1: + resolution: {integrity: sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==} + + sirv@3.0.0: + resolution: {integrity: sha512-BPwJGUeDaDCHihkORDchNyyTvWFhcusy1XMmhEVTQTwGeybFbp8YEmB+njbPnth1FibULBSBVwCQni25XlCUDg==} + engines: {node: '>=18'} + source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} @@ -452,6 +505,13 @@ packages: resolution: {integrity: sha512-qgHDV7AyvBZa2pbf+V0tnvWrN1LKD8LdUsBkR/SSYVVN6zXexiXnOy5Pjcjft2y/2NJJVa8ORUHFVn3oiWCLVQ==} engines: {node: '>=18'} + tiny-glob@0.2.9: + resolution: {integrity: sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==} + + totalist@3.0.1: + resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} + engines: {node: '>=6'} + tslib@2.8.0: resolution: {integrity: sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==} @@ -601,6 +661,8 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 + '@polka/url@1.0.0-next.28': {} + '@rollup/rollup-android-arm-eabi@4.24.2': optional: true @@ -655,6 +717,28 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.24.2': optional: true + '@sveltejs/adapter-static@3.0.6(@sveltejs/kit@2.7.3(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.4)(vite@5.4.10))(svelte@5.1.4)(vite@5.4.10))': + dependencies: + '@sveltejs/kit': 2.7.3(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.4)(vite@5.4.10))(svelte@5.1.4)(vite@5.4.10) + + '@sveltejs/kit@2.7.3(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.4)(vite@5.4.10))(svelte@5.1.4)(vite@5.4.10)': + dependencies: + '@sveltejs/vite-plugin-svelte': 4.0.0(svelte@5.1.4)(vite@5.4.10) + '@types/cookie': 0.6.0 + cookie: 0.6.0 + devalue: 5.1.1 + esm-env: 1.0.0 + import-meta-resolve: 4.1.0 + kleur: 4.1.5 + magic-string: 0.30.12 + mrmime: 2.0.0 + sade: 1.8.1 + set-cookie-parser: 2.7.1 + sirv: 3.0.0 + svelte: 5.1.4 + tiny-glob: 0.2.9 + vite: 5.4.10 + '@sveltejs/vite-plugin-svelte-inspector@3.0.1(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.4)(vite@5.4.10))(svelte@5.1.4)(vite@5.4.10)': dependencies: '@sveltejs/vite-plugin-svelte': 4.0.0(svelte@5.1.4)(vite@5.4.10) @@ -679,6 +763,8 @@ snapshots: '@tsconfig/svelte@5.0.4': {} + '@types/cookie@0.6.0': {} + '@types/estree@1.0.6': {} acorn-typescript@1.4.13(acorn@8.14.0): @@ -695,12 +781,16 @@ snapshots: dependencies: readdirp: 4.0.2 + cookie@0.6.0: {} + debug@4.3.7: dependencies: ms: 2.1.3 deepmerge@4.3.1: {} + devalue@5.1.1: {} + esbuild@0.21.5: optionalDependencies: '@esbuild/aix-ppc64': 0.21.5 @@ -739,6 +829,12 @@ snapshots: fsevents@2.3.3: optional: true + globalyzer@0.1.0: {} + + globrex@0.1.2: {} + + import-meta-resolve@4.1.0: {} + is-reference@3.0.2: dependencies: '@types/estree': 1.0.6 @@ -757,6 +853,8 @@ snapshots: mri@1.2.0: {} + mrmime@2.0.0: {} + ms@2.1.3: {} nanoid@3.3.7: {} @@ -799,6 +897,14 @@ snapshots: dependencies: mri: 1.2.0 + set-cookie-parser@2.7.1: {} + + sirv@3.0.0: + dependencies: + '@polka/url': 1.0.0-next.28 + mrmime: 2.0.0 + totalist: 3.0.1 + source-map-js@1.2.1: {} svelte-check@4.0.5(svelte@5.1.4)(typescript@5.6.3): @@ -829,6 +935,13 @@ snapshots: magic-string: 0.30.12 zimmerframe: 1.1.2 + tiny-glob@0.2.9: + dependencies: + globalyzer: 0.1.0 + globrex: 0.1.2 + + totalist@3.0.1: {} + tslib@2.8.0: {} typescript@5.6.3: {} diff --git a/src/App.svelte b/src/App.svelte deleted file mode 100644 index 12d7147..0000000 --- a/src/App.svelte +++ /dev/null @@ -1,68 +0,0 @@ - - -
-
-
nandi's blog
-
- https://atproto-browser.vercel.app/at/did:plc:ngokl2gnmpbvuvrfckja3g7p/com.whtwnd.blog.entry -
-
- {#each entries as entry} -
-
{entry.value.title}
-
{moment(entry.value.createdAt).fromNow()}
-
{@html marked.parse(entry.value.content)}
-
- {/each} -
- - diff --git a/src/app.d.ts b/src/app.d.ts new file mode 100644 index 0000000..da08e6d --- /dev/null +++ b/src/app.d.ts @@ -0,0 +1,13 @@ +// See https://svelte.dev/docs/kit/types#app.d.ts +// for information about these interfaces +declare global { + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface PageState {} + // interface Platform {} + } +} + +export {}; diff --git a/index.html b/src/app.html similarity index 83% rename from index.html rename to src/app.html index e23c34e..fe8ec9c 100644 --- a/index.html +++ b/src/app.html @@ -9,9 +9,9 @@ href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css" /> nandi's blog + %sveltekit.head% -
- +
%sveltekit.body%
diff --git a/src/main.ts b/src/main.ts index 928b6c5..50c470a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ import { mount } from 'svelte' -import App from './App.svelte' +import App from './routes/+page.svelte' const app = mount(App, { target: document.getElementById('app')!, diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte new file mode 100644 index 0000000..e03eace --- /dev/null +++ b/src/routes/+layout.svelte @@ -0,0 +1,24 @@ + + +
+
+ +
+ https://atproto-browser.vercel.app/at/did:plc:ngokl2gnmpbvuvrfckja3g7p/com.whtwnd.blog.entry +
+
+ {@render children()} +
+ + diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts new file mode 100644 index 0000000..176ae64 --- /dev/null +++ b/src/routes/+layout.ts @@ -0,0 +1 @@ +export const prerender = true diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte new file mode 100644 index 0000000..d91dc92 --- /dev/null +++ b/src/routes/+page.svelte @@ -0,0 +1,35 @@ + + +{#each entries as entry} +
+
+ {entry.value.title} +
+
{moment(entry.value.createdAt).fromNow()}
+
{@html marked.parse(entry.value.content)}
+
+{/each} diff --git a/src/routes/[rkey]/+page.svelte b/src/routes/[rkey]/+page.svelte new file mode 100644 index 0000000..dbf68a4 --- /dev/null +++ b/src/routes/[rkey]/+page.svelte @@ -0,0 +1,43 @@ + + +{#if entry} +
+
+ {entry.value.title} +
+
{moment(entry.value.createdAt).fromNow()}
+
{@html marked.parse(entry.value.content)}
+
+{/if} + + diff --git a/svelte.config.js b/svelte.config.js index b0683fd..7166fa8 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,7 +1,22 @@ -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' +// import adapter from '@sveltejs/adapter-auto'; +import adapter from '@sveltejs/adapter-static'; +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; -export default { - // Consult https://svelte.dev/docs#compile-time-svelte-preprocess - // for more information about preprocessors - preprocess: vitePreprocess(), -} +/** @type {import('@sveltejs/kit').Config} */ +const config = { + // Consult https://svelte.dev/docs/kit/integrations + // for more information about preprocessors + preprocess: vitePreprocess(), + + kit: { + // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. + // If your environment is not supported, or you settled on a specific environment, switch out the adapter. + // See https://svelte.dev/docs/kit/adapters for more information about adapters. + adapter: adapter(), + paths:{ + base: "" + } + } +}; + +export default config; diff --git a/tsconfig.json b/tsconfig.json index 80d1413..0b2d886 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,19 @@ { - "extends": "@tsconfig/svelte/tsconfig.json", - "compilerOptions": { - "target": "ESNext", - "types": ["@atcute/whitewind/lexicons"], - "useDefineForClassFields": true, - "module": "ESNext", - "resolveJsonModule": true, - /** - * Typecheck JS in `.svelte` and `.js` files by default. - * Disable checkJs if you'd like to use dynamic types in JS. - * Note that setting allowJs false does not prevent the use - * of JS in `.svelte` files. - */ - "allowJs": true, - "checkJs": true, - "isolatedModules": true, - "moduleDetection": "force" - }, - "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], - "references": [{ "path": "./tsconfig.node.json" }] + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler" + } + // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias + // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files + // + // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes + // from the referenced tsconfig.json - TypeScript does not merge them in } diff --git a/vite.config.ts b/vite.config.ts index f304a7a..8f69a1a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,8 +1,8 @@ import { defineConfig } from 'vite' -import { svelte } from '@sveltejs/vite-plugin-svelte' +import { sveltekit } from '@sveltejs/kit/vite'; // https://vite.dev/config/ export default defineConfig({ - plugins: [svelte()], - base: "./" + plugins: [sveltekit()], + })