add svelte and progress

This commit is contained in:
Niccolo Borgioli 2024-11-22 01:19:50 +01:00
parent 5615e62d41
commit 40cbf9b82e
6 changed files with 265 additions and 8 deletions

View File

@ -5,11 +5,13 @@ import mdx from '@astrojs/mdx'
import sitemap from '@astrojs/sitemap'
import { remarkReadingTime } from './readingTime'
import svelte from '@astrojs/svelte';
// https://astro.build/config
export default defineConfig({
site: 'https://example.com',
integrations: [mdx(), sitemap()],
integrations: [mdx(), sitemap(), svelte()],
markdown: {
remarkPlugins: [remarkReadingTime],
},
})
})

View File

@ -13,12 +13,14 @@
"@astrojs/mdx": "^3.1.9",
"@astrojs/rss": "^4.0.9",
"@astrojs/sitemap": "^3.2.1",
"@astrojs/svelte": "^6.0.2",
"@fontsource-variable/jost": "^5.1.1",
"@fontsource-variable/playfair-display": "^5.1.0",
"astro": "^4.16.13",
"mdast-util-to-string": "^4.0.0",
"reading-time": "^1.5.0",
"sharp": "^0.33.5",
"svelte": "^5.2.7",
"typescript": "^5.6.3"
},
"packageManager": "pnpm@9.12.3"

179
pnpm-lock.yaml generated
View File

@ -20,6 +20,9 @@ importers:
'@astrojs/sitemap':
specifier: ^3.2.1
version: 3.2.1
'@astrojs/svelte':
specifier: ^6.0.2
version: 6.0.2(astro@4.16.13(rollup@4.27.3)(typescript@5.6.3))(svelte@5.2.7)(typescript@5.6.3)
'@fontsource-variable/jost':
specifier: ^5.1.1
version: 5.1.1
@ -38,6 +41,9 @@ importers:
sharp:
specifier: ^0.33.5
version: 0.33.5
svelte:
specifier: ^5.2.7
version: 5.2.7
typescript:
specifier: ^5.6.3
version: 5.6.3
@ -91,6 +97,14 @@ packages:
'@astrojs/sitemap@3.2.1':
resolution: {integrity: sha512-uxMfO8f7pALq0ADL6Lk68UV6dNYjJ2xGUzyjjVj60JLBs5a6smtlkBYv3tQ0DzoqwS7c9n4FUx5lgv0yPo/fgA==}
'@astrojs/svelte@6.0.2':
resolution: {integrity: sha512-Jn60LLH+AbjtLIOQuL0SUI0fxMwpT89VraoGkEwF33ZgCT59H8fMQOj9eNf632P/SHRbKpD+Q+PJjODn5OcKoQ==}
engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0}
peerDependencies:
astro: ^4.0.0
svelte: ^5.1.16
typescript: ^5.3.3
'@astrojs/telemetry@3.1.0':
resolution: {integrity: sha512-/ca/+D8MIKEC8/A9cSaPUqQNZm+Es/ZinRv0ZAzvu2ios7POQSsVD+VOj7/hypWNsNM3T7RpfgNq7H2TU1KEHA==}
engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0}
@ -604,6 +618,21 @@ packages:
'@shikijs/vscode-textmate@9.3.0':
resolution: {integrity: sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==}
'@sveltejs/vite-plugin-svelte-inspector@3.0.1':
resolution: {integrity: sha512-2CKypmj1sM4GE7HjllT7UKmo4Q6L5xFRd7VMGEWhYnZ+wc6AUVU01IBd7yUi6WnFndEwWoMNOd6e8UjoN0nbvQ==}
engines: {node: ^18.0.0 || ^20.0.0 || >=22}
peerDependencies:
'@sveltejs/vite-plugin-svelte': ^4.0.0-next.0||^4.0.0
svelte: ^5.0.0-next.96 || ^5.0.0
vite: ^5.0.0
'@sveltejs/vite-plugin-svelte@4.0.1':
resolution: {integrity: sha512-prXoAE/GleD2C4pKgHa9vkdjpzdYwCSw/kmjw6adIyu0vk5YKCfqIztkLg10m+kOYnzZu3bb0NaPTxlWre2a9Q==}
engines: {node: ^18.0.0 || ^20.0.0 || >=22}
peerDependencies:
svelte: ^5.0.0-next.96 || ^5.0.0
vite: ^5.0.0
'@types/acorn@4.0.6':
resolution: {integrity: sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==}
@ -692,6 +721,11 @@ packages:
peerDependencies:
acorn: ^6.0.0 || ^7.0.0 || ^8.0.0
acorn-typescript@1.4.13:
resolution: {integrity: sha512-xsc9Xv0xlVfwp2o7sQ+GCQ1PgbkdcpWdTzrwXxO3xDMTAywVS3oXVOcOHuRjAPkS4P9b+yc/qNF15460v+jp4Q==}
peerDependencies:
acorn: '>=8.9.0'
acorn@8.14.0:
resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==}
engines: {node: '>=0.4.0'}
@ -868,6 +902,13 @@ packages:
decode-named-character-reference@1.0.2:
resolution: {integrity: sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==}
dedent-js@1.0.1:
resolution: {integrity: sha512-OUepMozQULMLUmhxS95Vudo0jb0UchLimi3+pQ2plj61Fcy8axbP9hbiD4Sz6DPqn6XG3kfmziVfQ1rSys5AJQ==}
deepmerge@4.3.1:
resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==}
engines: {node: '>=0.10.0'}
dequal@2.0.3:
resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
engines: {node: '>=6'}
@ -938,11 +979,17 @@ packages:
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
engines: {node: '>=12'}
esm-env@1.1.4:
resolution: {integrity: sha512-oO82nKPHKkzIj/hbtuDYy/JHqBHFlMIW36SDiPCVsj87ntDLcWN+sJ1erdVryd4NxODacFTsdrIE3b7IamqbOg==}
esprima@4.0.1:
resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==}
engines: {node: '>=4'}
hasBin: true
esrap@1.2.2:
resolution: {integrity: sha512-F2pSJklxx1BlQIQgooczXCPHmcWpn6EsP5oo73LQfonG9fIlIENQ8vMmfGXeojP9MrkzUNAfyU5vdFlR9shHAw==}
estree-util-attach-comments@3.0.0:
resolution: {integrity: sha512-cKUwm/HUcTDsYh/9FgnuFqpfquUbwIqwKM26BVCGDPVgvaCl/nDCCjUfiLlx6lsEZ3Z4RFxNbOQ60pkaEwFxGw==}
@ -1155,6 +1202,9 @@ packages:
resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}
engines: {node: '>=12'}
is-reference@3.0.3:
resolution: {integrity: sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==}
is-unicode-supported@1.3.0:
resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==}
engines: {node: '>=12'}
@ -1213,6 +1263,9 @@ packages:
resolution: {integrity: sha512-OfCBkGEw4nN6JLtgRidPX6QxjBQGQf72q3si2uvqyFEMbycSFFHwAZeXx6cJgFM9wmLrf9zBwCP3Ivqa+LLZPw==}
engines: {node: '>=6'}
locate-character@3.0.0:
resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==}
locate-path@5.0.0:
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
engines: {node: '>=8'}
@ -1227,6 +1280,9 @@ packages:
longest-streak@3.1.0:
resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}
lower-case@2.0.2:
resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==}
lru-cache@5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
@ -1433,6 +1489,9 @@ packages:
nlcst-to-string@4.0.0:
resolution: {integrity: sha512-YKLBCcUYKAg0FNlOBT6aI91qFmSiFKiluk655WzPF+DDMA02qIyy8uiRqI8QXtcFpEvll12LpL5MXqEmAZ+dcA==}
no-case@3.0.4:
resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==}
node-releases@2.0.18:
resolution: {integrity: sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==}
@ -1480,6 +1539,9 @@ packages:
parse5@7.2.1:
resolution: {integrity: sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ==}
pascal-case@3.1.2:
resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==}
path-browserify@1.0.1:
resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==}
@ -1732,6 +1794,16 @@ packages:
style-to-object@1.0.8:
resolution: {integrity: sha512-xT47I/Eo0rwJmaXC4oilDGDWLohVhR6o/xAQcPQN8q6QBuZVL8qMYL85kLmST5cPjAorwvqIA4qXTRQoYHaL6g==}
svelte2tsx@0.7.26:
resolution: {integrity: sha512-cBGGZ3Hejuh9gYICQcGKg1zyYhrzZR04iTUdP5pD+CIbjoZiyzS4cpCi4IHh0PA2Vf6cFuwVRmDs9wnOfJotJA==}
peerDependencies:
svelte: ^3.55 || ^4.0.0-next.0 || ^4.0 || ^5.0.0-next.0
typescript: ^4.9.4 || ^5.0.0
svelte@5.2.7:
resolution: {integrity: sha512-cEhPGuLHiH2+Z8B1FwQgiZJgA39uUmJR4516TKrM5zrp0/cuwJkfhUfcTxhAkznanAF5fXUKzvYR4o+Ksx3ZCQ==}
engines: {node: '>=18'}
tinyexec@0.3.1:
resolution: {integrity: sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==}
@ -2024,6 +2096,9 @@ packages:
resolution: {integrity: sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==}
engines: {node: '>=12.20'}
zimmerframe@1.1.2:
resolution: {integrity: sha512-rAbqEGa8ovJy4pyBxZM70hg4pE6gDgaQ0Sl9M3enG3I0d6H4XSAM3GeNGLKnsBpuijUow064sf7ww1nutC5/3w==}
zod-to-json-schema@3.23.5:
resolution: {integrity: sha512-5wlSS0bXfF/BrL4jPAbz9da5hDlDptdEppYfe+x4eIJ7jioqKG9uUxOwPzqof09u/XeVdrgFu29lZi+8XNDJtA==}
peerDependencies:
@ -2144,6 +2219,25 @@ snapshots:
stream-replace-string: 2.0.0
zod: 3.23.8
'@astrojs/svelte@6.0.2(astro@4.16.13(rollup@4.27.3)(typescript@5.6.3))(svelte@5.2.7)(typescript@5.6.3)':
dependencies:
'@sveltejs/vite-plugin-svelte': 4.0.1(svelte@5.2.7)(vite@5.4.11)
astro: 4.16.13(rollup@4.27.3)(typescript@5.6.3)
svelte: 5.2.7
svelte2tsx: 0.7.26(svelte@5.2.7)(typescript@5.6.3)
typescript: 5.6.3
vite: 5.4.11
transitivePeerDependencies:
- '@types/node'
- less
- lightningcss
- sass
- sass-embedded
- stylus
- sugarss
- supports-color
- terser
'@astrojs/telemetry@3.1.0':
dependencies:
ci-info: 4.1.0
@ -2606,6 +2700,28 @@ snapshots:
'@shikijs/vscode-textmate@9.3.0': {}
'@sveltejs/vite-plugin-svelte-inspector@3.0.1(@sveltejs/vite-plugin-svelte@4.0.1(svelte@5.2.7)(vite@5.4.11))(svelte@5.2.7)(vite@5.4.11)':
dependencies:
'@sveltejs/vite-plugin-svelte': 4.0.1(svelte@5.2.7)(vite@5.4.11)
debug: 4.3.7
svelte: 5.2.7
vite: 5.4.11
transitivePeerDependencies:
- supports-color
'@sveltejs/vite-plugin-svelte@4.0.1(svelte@5.2.7)(vite@5.4.11)':
dependencies:
'@sveltejs/vite-plugin-svelte-inspector': 3.0.1(@sveltejs/vite-plugin-svelte@4.0.1(svelte@5.2.7)(vite@5.4.11))(svelte@5.2.7)(vite@5.4.11)
debug: 4.3.7
deepmerge: 4.3.1
kleur: 4.1.5
magic-string: 0.30.13
svelte: 5.2.7
vite: 5.4.11
vitefu: 1.0.3(vite@5.4.11)
transitivePeerDependencies:
- supports-color
'@types/acorn@4.0.6':
dependencies:
'@types/estree': 1.0.6
@ -2725,6 +2841,10 @@ snapshots:
dependencies:
acorn: 8.14.0
acorn-typescript@1.4.13(acorn@8.14.0):
dependencies:
acorn: 8.14.0
acorn@8.14.0: {}
ajv@8.17.1:
@ -2943,6 +3063,10 @@ snapshots:
dependencies:
character-entities: 2.0.2
dedent-js@1.0.1: {}
deepmerge@4.3.1: {}
dequal@2.0.3: {}
detect-libc@2.0.3: {}
@ -3024,8 +3148,15 @@ snapshots:
escape-string-regexp@5.0.0: {}
esm-env@1.1.4: {}
esprima@4.0.1: {}
esrap@1.2.2:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.0
'@types/estree': 1.0.6
estree-util-attach-comments@3.0.0:
dependencies:
'@types/estree': 1.0.6
@ -3308,6 +3439,10 @@ snapshots:
is-plain-obj@4.1.0: {}
is-reference@3.0.3:
dependencies:
'@types/estree': 1.0.6
is-unicode-supported@1.3.0: {}
is-unicode-supported@2.1.0: {}
@ -3350,6 +3485,8 @@ snapshots:
pify: 4.0.1
strip-bom: 3.0.0
locate-character@3.0.0: {}
locate-path@5.0.0:
dependencies:
p-locate: 4.1.0
@ -3363,6 +3500,10 @@ snapshots:
longest-streak@3.1.0: {}
lower-case@2.0.2:
dependencies:
tslib: 2.8.1
lru-cache@5.1.1:
dependencies:
yallist: 3.1.1
@ -3839,6 +3980,11 @@ snapshots:
dependencies:
'@types/nlcst': 2.0.3
no-case@3.0.4:
dependencies:
lower-case: 2.0.2
tslib: 2.8.1
node-releases@2.0.18: {}
onetime@7.0.0:
@ -3908,6 +4054,11 @@ snapshots:
dependencies:
entities: 4.5.0
pascal-case@3.1.2:
dependencies:
no-case: 3.0.4
tslib: 2.8.1
path-browserify@1.0.1: {}
path-exists@4.0.0: {}
@ -4255,6 +4406,29 @@ snapshots:
dependencies:
inline-style-parser: 0.2.4
svelte2tsx@0.7.26(svelte@5.2.7)(typescript@5.6.3):
dependencies:
dedent-js: 1.0.1
pascal-case: 3.1.2
svelte: 5.2.7
typescript: 5.6.3
svelte@5.2.7:
dependencies:
'@ampproject/remapping': 2.3.0
'@jridgewell/sourcemap-codec': 1.5.0
'@types/estree': 1.0.6
acorn: 8.14.0
acorn-typescript: 1.4.13(acorn@8.14.0)
aria-query: 5.3.2
axobject-query: 4.1.0
esm-env: 1.1.4
esrap: 1.2.2
is-reference: 3.0.3
locate-character: 3.0.0
magic-string: 0.30.13
zimmerframe: 1.1.2
tinyexec@0.3.1: {}
to-regex-range@5.0.1:
@ -4269,8 +4443,7 @@ snapshots:
optionalDependencies:
typescript: 5.6.3
tslib@2.8.1:
optional: true
tslib@2.8.1: {}
type-fest@4.27.0: {}
@ -4543,6 +4716,8 @@ snapshots:
yocto-queue@1.1.1: {}
zimmerframe@1.1.2: {}
zod-to-json-schema@3.23.5(zod@3.23.8):
dependencies:
zod: 3.23.8

View File

@ -0,0 +1,75 @@
<script lang="ts">
import { onMount } from 'svelte'
import { spring } from 'svelte/motion'
const springed = spring(
{ scroll: 0 },
{
stiffness: 0.05,
damping: 0.7,
}
)
let el: SVGElement
let scroll = 0
function updateState(value: number) {
const max = 359.99999
const R = 50
let alpha = (360 / 1) * value
alpha = Math.min(alpha, max)
const a = ((90 - alpha) * Math.PI) / 180
const x = R + R * Math.cos(a) * 2
const y = R - R * Math.sin(a) * 2
const center = alpha > 180 ? 1 : 0
const path = `M${R},${-50} A${R * 2},${R * 2},0,${center},1,${x},${y} L${R},${R} L${R},${-R}`
if (el) el.setAttribute('d', path)
}
function updateScroll() {
const el = window.document.documentElement
const percentage = el.scrollTop / (el.scrollHeight - el.clientHeight)
scroll = isNaN(percentage) ? 0 : percentage
}
onMount(() => {
const el = window.document
el.addEventListener('scroll', updateScroll, false)
updateScroll()
return () => {
el.removeEventListener('scroll', updateScroll)
}
})
$: springed.set({ scroll })
$: updateState($springed.scroll)
</script>
<div>
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" version="1.1">
<path bind:this={el} fill="var(--clr-secondary)" d="" />
</svg>
<span>{scroll.toFixed(2)}</span>
</div>
<style>
div {
position: fixed;
bottom: 1em;
right: 1em;
pointer-events: none;
text-align: center;
}
span {
display: block;
font-size: 0.5em;
background-color: var(--clr-primary);
height: 1.5em;
}
svg {
border: 0.125em solid var(--clr-primary);
width: 2em;
height: 2em;
}
</style>

View File

@ -1,8 +1,7 @@
---
import BaseHead from '../components/BaseHead.astro'
// import Footer from '../components/Footer.astro'
// import Header from '../components/Header.astro'
import Nav from '../components/Nav.astro'
import Progress from '../components/Progress.svelte'
---
<!doctype html>
@ -11,12 +10,11 @@ import Nav from '../components/Nav.astro'
<BaseHead />
</head>
<body>
<!-- <Header /> -->
<Nav />
<main>
<slot />
</main>
<!-- <Footer /> -->
<Progress client:only="svelte" />
</body>
</html>

5
svelte.config.js Normal file
View File

@ -0,0 +1,5 @@
import { vitePreprocess } from '@astrojs/svelte';
export default {
preprocess: vitePreprocess(),
}