Migrate from Svelte 4 to Svelte 5
This commit is contained in:
parent
6043dece34
commit
e1c2565db2
8 changed files with 232 additions and 644 deletions
775
package-lock.json
generated
775
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@
|
||||||
"@sveltejs/adapter-auto": "^3.3.1",
|
"@sveltejs/adapter-auto": "^3.3.1",
|
||||||
"@sveltejs/adapter-static": "^3.0.8",
|
"@sveltejs/adapter-static": "^3.0.8",
|
||||||
"@sveltejs/kit": "^2.20.2",
|
"@sveltejs/kit": "^2.20.2",
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
"@sveltejs/vite-plugin-svelte": "^4.0.4",
|
||||||
"@types/eslint": "^9.6.1",
|
"@types/eslint": "^9.6.1",
|
||||||
"eslint": "^9.23.0",
|
"eslint": "^9.23.0",
|
||||||
"eslint-plugin-svelte": "^2.46.1",
|
"eslint-plugin-svelte": "^2.46.1",
|
||||||
|
@ -24,8 +24,8 @@
|
||||||
"rehype-external-links": "^3.0.0",
|
"rehype-external-links": "^3.0.0",
|
||||||
"remark-emoji": "^4.0.1",
|
"remark-emoji": "^4.0.1",
|
||||||
"remark-gfm": "^4.0.1",
|
"remark-gfm": "^4.0.1",
|
||||||
"svelte": "^4.2.19",
|
"svelte": "^5.25.3",
|
||||||
"svelte-check": "^3.8.6",
|
"svelte-check": "^4.1.5",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.2",
|
||||||
"vite": "^5.4.15"
|
"vite": "^5.4.15"
|
||||||
|
|
|
@ -1,45 +1,45 @@
|
||||||
<script>
|
<script>
|
||||||
import DateTime from "./DateTime.svelte";
|
import DateTime from "./DateTime.svelte";
|
||||||
import { page } from "$app/stores";
|
import { page } from "$app/state";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
{#if $page.data.header}
|
{#if page.data.header}
|
||||||
<meta property="og:image" content={$page.data.header} />
|
<meta property="og:image" content={page.data.header} />
|
||||||
{#if $page.data.header_alt}
|
{#if page.data.header_alt}
|
||||||
<meta property="og:image:alt" content={$page.data.header_alt} />
|
<meta property="og:image:alt" content={page.data.header_alt} />
|
||||||
{/if}
|
{/if}
|
||||||
<meta property="og:description" content={$page.data.description} />
|
<meta property="og:description" content={page.data.description} />
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<header id="main-content">
|
<header id="main-content">
|
||||||
{#if $page.data.header}
|
{#if page.data.header}
|
||||||
<figure>
|
<figure>
|
||||||
<img
|
<img
|
||||||
src={$page.data.header}
|
src={page.data.header}
|
||||||
alt={$page.data.header_alt || "header"}
|
alt={page.data.header_alt || "header"}
|
||||||
class="header"
|
class="header"
|
||||||
/>
|
/>
|
||||||
{#if $page.data.header_caption}
|
{#if page.data.header_caption}
|
||||||
<figcaption>{$page.data.header_caption}</figcaption>
|
<figcaption>{page.data.header_caption}</figcaption>
|
||||||
{/if}
|
{/if}
|
||||||
</figure>
|
</figure>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<hgroup>
|
<hgroup>
|
||||||
<h1>{$page.data.title}</h1>
|
<h1>{page.data.title}</h1>
|
||||||
<p>{$page.data.description}</p>
|
<p>{page.data.description}</p>
|
||||||
</hgroup>
|
</hgroup>
|
||||||
|
|
||||||
{#if $page.data.published}
|
{#if page.data.published}
|
||||||
<p>
|
<p>
|
||||||
<small>
|
<small>
|
||||||
Published:
|
Published:
|
||||||
<DateTime datetime={$page.data.published} display="date" />
|
<DateTime datetime={page.data.published} display="date" />
|
||||||
{#if $page.data.edited}
|
{#if page.data.edited}
|
||||||
• Last edited:
|
• Last edited:
|
||||||
<DateTime datetime={$page.data.edited} display="dateTime" />
|
<DateTime datetime={page.data.edited} display="dateTime" />
|
||||||
{/if}
|
{/if}
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
<script>
|
<script>
|
||||||
import { browser } from "$app/environment";
|
import { browser } from "$app/environment";
|
||||||
|
|
||||||
/** @type string | undefined */
|
|
||||||
export let datetime = undefined;
|
|
||||||
/** @type "date" | "dateTime" | "time" */
|
|
||||||
export let display = "date";
|
/**
|
||||||
/** @type string | undefined */
|
* @typedef {Object} Props
|
||||||
export let timeZone = undefined;
|
* @property {any} [datetime]
|
||||||
|
* @property {string} [display]
|
||||||
|
* @property {any} [timeZone]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { datetime = undefined, display = "date", timeZone = undefined } = $props();
|
||||||
|
|
||||||
const date = datetime ? Date.parse(datetime) : Date.now();
|
const date = datetime ? Date.parse(datetime) : Date.now();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { page } from "$app/stores";
|
import { page } from "$app/state";
|
||||||
import links from "../../data/links.json";
|
import links from "../../data/links.json";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
<img src="/favicon.png" alt="a black cat with large eyes" />
|
<img src="/favicon.png" alt="a black cat with large eyes" />
|
||||||
<a href="/">pancakes</a>
|
<a href="/">pancakes</a>
|
||||||
</span>
|
</span>
|
||||||
{#if $page.url.pathname !== "/"}
|
{#if page.url.pathname !== "/"}
|
||||||
<ul class="links">
|
<ul class="links">
|
||||||
{#each links as link}
|
{#each links as link}
|
||||||
{#if link.href && !link.mainOnly}
|
{#if link.href && !link.mainOnly}
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
<script>
|
<script>
|
||||||
import { browser } from "$app/environment";
|
import { browser } from "$app/environment";
|
||||||
import { page } from "$app/stores";
|
import { page } from "$app/state";
|
||||||
import Footer from "$lib/components/Footer.svelte";
|
import Footer from "$lib/components/Footer.svelte";
|
||||||
import Navbar from "$lib/components/Navbar.svelte";
|
import Navbar from "$lib/components/Navbar.svelte";
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import('svelte').Snippet} [children]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { children } = $props();
|
||||||
|
|
||||||
const green = browser
|
const green = browser
|
||||||
? window.localStorage.getItem("green") === "true"
|
? window.localStorage.getItem("green") === "true"
|
||||||
|
@ -15,16 +22,16 @@
|
||||||
<link rel="stylesheet" href="/assets/green.css" />
|
<link rel="stylesheet" href="/assets/green.css" />
|
||||||
{/if}
|
{/if}
|
||||||
<title>
|
<title>
|
||||||
{$page.data.title ? $page.data.title + " | pancakes" : "pancakes"}
|
{page.data.title ? page.data.title + " | pancakes" : "pancakes"}
|
||||||
</title>
|
</title>
|
||||||
<meta name="description" content={$page.data.description || "🐈⬛"} />
|
<meta name="description" content={page.data.description || "🐈⬛"} />
|
||||||
<meta property="og:site_name" content="pancakes" />
|
<meta property="og:site_name" content="pancakes" />
|
||||||
<meta
|
<meta
|
||||||
property="og:url"
|
property="og:url"
|
||||||
content={"https://pancakes.gay" + $page.url.pathname}
|
content={"https://pancakes.gay" + page.url.pathname}
|
||||||
/>
|
/>
|
||||||
<meta property="og:title" content={$page.data.title || "pancakes"} />
|
<meta property="og:title" content={page.data.title || "pancakes"} />
|
||||||
{#if $page.data.header}
|
{#if page.data.header}
|
||||||
<meta property="og:type" content="article" />
|
<meta property="og:type" content="article" />
|
||||||
{:else}
|
{:else}
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
|
@ -35,6 +42,6 @@
|
||||||
|
|
||||||
<Navbar />
|
<Navbar />
|
||||||
|
|
||||||
<slot />
|
{@render children?.()}
|
||||||
|
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
const pages = getPages();
|
const pages = getPages();
|
||||||
|
|
||||||
let ntfyLock = false;
|
let ntfyLock = $state(false);
|
||||||
async function sendNtfyMessage() {
|
async function sendNtfyMessage() {
|
||||||
if (ntfyLock) return;
|
if (ntfyLock) return;
|
||||||
ntfyLock = true;
|
ntfyLock = true;
|
||||||
|
@ -396,7 +396,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
on:input={updateNtfyCharCount}
|
oninput={updateNtfyCharCount}
|
||||||
type="text"
|
type="text"
|
||||||
id="ntfy-message"
|
id="ntfy-message"
|
||||||
name="ntfy-message"
|
name="ntfy-message"
|
||||||
|
@ -408,7 +408,7 @@
|
||||||
128
|
128
|
||||||
</label>
|
</label>
|
||||||
<br />
|
<br />
|
||||||
<button on:click={sendNtfyMessage} style="margin-top: 1rem;" disabled={ntfyLock}> Send </button>
|
<button onclick={sendNtfyMessage} style="margin-top: 1rem;" disabled={ntfyLock}> Send </button>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -2,8 +2,14 @@
|
||||||
import ArticleHeader from "$lib/components/ArticleHeader.svelte";
|
import ArticleHeader from "$lib/components/ArticleHeader.svelte";
|
||||||
import { error } from "@sveltejs/kit";
|
import { error } from "@sveltejs/kit";
|
||||||
|
|
||||||
/** @type {import("./$types").PageData} */
|
|
||||||
export let data;
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {import("./$types").PageData} data
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let { data } = $props();
|
||||||
|
|
||||||
// hopefully this will get my attention
|
// hopefully this will get my attention
|
||||||
if (!data.title) error(500, "there is no title dumbass");
|
if (!data.title) error(500, "there is no title dumbass");
|
||||||
|
@ -13,5 +19,5 @@
|
||||||
<article id="main-content">
|
<article id="main-content">
|
||||||
<ArticleHeader />
|
<ArticleHeader />
|
||||||
|
|
||||||
<svelte:component this={data.content} />
|
<data.content />
|
||||||
</article>
|
</article>
|
||||||
|
|
Loading…
Add table
Reference in a new issue