From e8651f6557ab06a4208fd176bade9cb457d18464 Mon Sep 17 00:00:00 2001 From: Henri Date: Fri, 21 Nov 2025 03:15:09 +0200 Subject: [PATCH] custom router now working --- README.md | 149 ++++++++++++--- index.html | 6 +- package-lock.json | 14 +- package.json | 3 - 404.html => public/404.html | 0 public/CNAME.example | 1 + src/App.svelte | 26 +-- src/app.css | 361 +++++++++++++++++++++++------------- src/lib/Router.svelte | 46 +++++ src/lib/router.svelte.js | 0 src/lib/theme.js | 6 +- src/routes/Demo.svelte | 3 +- src/routes/Home.svelte | 6 +- src/routes/index.js | 5 +- 14 files changed, 435 insertions(+), 191 deletions(-) rename 404.html => public/404.html (100%) create mode 100644 public/CNAME.example create mode 100644 src/lib/Router.svelte delete mode 100644 src/lib/router.svelte.js diff --git a/README.md b/README.md index 54a2631..beee597 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,136 @@ -# Svelte + Vite +# Lapikud External Website -This template should help get you started developing with Svelte in Vite. +Built with [Svelte 5](https://svelte.dev/) and [Vite](https://vite.dev/). -## Recommended IDE Setup +## Development plan -[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). +Materials are on `Google Drive > Lapikud > Tarkvara > Vรคliveeb` -## Need an official Svelte framework? +## Contribution guide -Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more. +### 1. Create Issues -## Technical considerations +Easiest way to help would be to create issues about things that are missing and wrong -**Why use this over SvelteKit?** +### 2. Fork this repo and create a pull request -- It brings its own routing solution which might not be preferable for some users. -- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app. +Fork this repo to your own account and create a pull request for changes you have done in there -This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project. +## How to setup development environment -Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate. +### Prerequisites -**Why include `.vscode/extensions.json`?** +- [Node.js](https://nodejs.org/) (v18 or higher. v20 is recommended) +- npm (comes with Node.js) -Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project. +### Installation -**Why enable `checkJs` in the JS template?** +1. **Clone the repository** -It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration. - -**Why is HMR not preserving my local component state?** - -HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/sveltejs/svelte-hmr/tree/master/packages/svelte-hmr#preservation-of-local-state). - -If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR. - -```js -// store.js -// An extremely simple external store -import { writable } from 'svelte/store' -export default writable(0) +```bash + git clone https://github.com/Lapikud/lapikud.github.io.git + cd lapikud.github.io ``` + +2. **Install dependencies** + +```bash + npm install +``` + +3. **Start development server** + +```bash + npm run dev +``` + +### Optional (secretly required): Image optimization + +> [!WARNING] +> No one wants to download 5MB images that are then shown in a 100x100px box. + +**Always optimize images before committing them!** + +
+Linux/Windows (WSL/Ubuntu) + +```bash +sudo apt install ffmpeg +``` + +```bash +# For thumbnails/small images (100-300px display) +ffmpeg -i input -vf scale=400:-1 output.jpg + +# For medium images (300-800px display) +ffmpeg -i input -vf scale=1200:-1 output.jpg + +# For full-width hero images +ffmpeg -i input -vf scale=1920:-1 output.jpg +``` + +
+ +
+Windows + +**Option 1: Using winget (Windows 11 or Windows 10 with App Installer)** + +```bash +winget install ffmpeg +``` + +**Option 2: Manual installation** + +1. Download FFmpeg from [ffmpeg.org/download.html](https://ffmpeg.org/download.html) +2. Extract the archive +3. Add the `bin` folder to your PATH environment variable + +**Usage:** + +```bash +# For thumbnails/small images (100-300px display) +ffmpeg -i input -vf scale=400:-1 output.jpg + +# For medium images (300-800px display) +ffmpeg -i input -vf scale=1200:-1 output.jpg + +# For full-width hero images +ffmpeg -i input -vf scale=1920:-1 output.jpg +``` + +
+ +
+MacOS + +```bash +brew install ffmpeg +``` + +```bash +# For thumbnails/small images (100-300px display) +ffmpeg -i input -vf scale=400:-1 output.jpg + +# For medium images (300-800px display) +ffmpeg -i input -vf scale=1200:-1 output.jpg + +# For full-width hero images +ffmpeg -i input -vf scale=1920:-1 output.jpg +``` + +
+ +## Build for production + +```bash +npm run build +``` + +Built files will be in the `dist/` folder. + +## Deploy + +Push to the `main` branch and GitHub Actions will automatically build and deploy to GitHub Pages. + +Deployment typically takes 2-5 minutes. You can check the progress in the [Actions tab](https://github.com/Lapikud/lapikud.github.io/actions). diff --git a/index.html b/index.html index 16bcdde..3b24afa 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + @@ -6,13 +6,13 @@ lapikud.github.io diff --git a/package-lock.json b/package-lock.json index 737be84..2dcfc40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,9 +7,6 @@ "": { "name": "lapikud.github.io", "version": "0.0.0", - "dependencies": { - "svelte-routing": "^2.13.0" - }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^6.2.1", "svelte": "^5.43.8", @@ -394,6 +391,7 @@ "integrity": "sha512-YZs/OSKOQAQCnJvM/P+F1URotNnYNeU3P2s4oIpzm1uFaqUEqRxUB0g5ejMjEb5Gjb9/PiBI5Ktrq4rUUF8UVQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@sveltejs/vite-plugin-svelte-inspector": "^5.0.0", "debug": "^4.4.1", @@ -451,6 +449,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -903,6 +902,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -988,6 +988,7 @@ "integrity": "sha512-K1QJbpc71OHs3egN/ZHN+nsH/eE/eJQUbtlTAAXVejOOjsFx9hM96fCX5fwPQIYclJfVS8D96RDFA76nZsrJ3w==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@jridgewell/remapping": "^2.3.4", "@jridgewell/sourcemap-codec": "^1.5.0", @@ -1008,12 +1009,6 @@ "node": ">=18" } }, - "node_modules/svelte-routing": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/svelte-routing/-/svelte-routing-2.13.0.tgz", - "integrity": "sha512-/NTxqTwLc7Dq306hARJrH2HLXOBtKd7hu8nxgoFDlK0AC4SOKnzisiX/9m8Uksei1QAWtlAEdF91YphNM8iDMg==", - "license": "MIT" - }, "node_modules/tinyglobby": { "version": "0.2.15", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", @@ -1046,6 +1041,7 @@ "integrity": "sha512-u09tdk/huMiN8xwoiBbig197jKdCamQTtOruSalOzbqGje3jdHiV0njQlAW0YvzoahkirFePNQ4RYlfnRQpXZA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@oxc-project/runtime": "0.97.0", "fdir": "^6.5.0", diff --git a/package.json b/package.json index 72cd43f..7d52e02 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,5 @@ }, "overrides": { "vite": "npm:rolldown-vite@7.2.5" - }, - "dependencies": { - "svelte-routing": "^2.13.0" } } diff --git a/404.html b/public/404.html similarity index 100% rename from 404.html rename to public/404.html diff --git a/public/CNAME.example b/public/CNAME.example new file mode 100644 index 0000000..8a1d543 --- /dev/null +++ b/public/CNAME.example @@ -0,0 +1 @@ +add later \ No newline at end of file diff --git a/src/App.svelte b/src/App.svelte index 7596a25..7d2a066 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,20 +1,20 @@ - - {#each Object.entries(routes) as [path, component]} - - {/each} - +