refactor: drop svelte-time, drop rehype plugins

This commit is contained in:
dusk 2025-02-22 18:02:55 +03:00
parent 4dd08def5c
commit e402a54f9c
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
4 changed files with 18 additions and 12 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -46,11 +46,8 @@
"@types/node-schedule": "^2.1.7", "@types/node-schedule": "^2.1.7",
"nanoid": "^5.1.0", "nanoid": "^5.1.0",
"node-schedule": "^2.1.1", "node-schedule": "^2.1.1",
"rehype-autolink-headings": "^7.1.0",
"rehype-slug": "^6.0.0",
"robots-parser": "^3.0.1", "robots-parser": "^3.0.1",
"steamgriddb": "^2.2.0", "steamgriddb": "^2.2.0"
"svelte-time": "^2.0.0"
}, },
"trustedDependencies": [ "trustedDependencies": [
"@sveltejs/kit", "@sveltejs/kit",

View File

@ -3,7 +3,6 @@
import Note from '../components/note.svelte'; import Note from '../components/note.svelte';
import Window from '../components/window.svelte'; import Window from '../components/window.svelte';
import LatestStuff from './lateststuff.md'; import LatestStuff from './lateststuff.md';
import Time from "svelte-time";
interface Props { interface Props {
data: any; data: any;
@ -20,6 +19,21 @@
minute: "2-digit", minute: "2-digit",
}) })
} }
const renderRelativeDate = (timestamp: number) => {
const elapsed = timestamp - (new Date()).getTime()
const units: Record<string, number> = {
year : 24 * 60 * 60 * 1000 * 365,
month : 24 * 60 * 60 * 1000 * 365/12,
day : 24 * 60 * 60 * 1000,
hour : 60 * 60 * 1000,
minute: 60 * 1000,
second: 1000
}
const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' })
for (var unit in units)
if (Math.abs(elapsed) > units[unit] || unit == 'second')
return rtf.format(Math.round(elapsed / units[unit]), unit as Intl.RelativeTimeFormatUnit)
}
</script> </script>
<div class="flex flex-col md:flex-row gap-y-2 lg:gap-y-0 md:h-full h-card"> <div class="flex flex-col md:flex-row gap-y-2 lg:gap-y-0 md:h-full h-card">
@ -157,9 +171,10 @@
<p <p
class="prose prose-ralsei p-1 border-4 text-sm bg-ralsei-black" class="prose prose-ralsei p-1 border-4 text-sm bg-ralsei-black"
style="border-style: double double none double;" style="border-style: double double none double;"
title={renderDate(data.lastNote.published)}
> >
<a href="/entries">last log was…</a> <a href="/entries">last log was…</a>
published <Time relative format="dddd @ h:mm A · MMMM D, YYYY" timestamp={data.lastNote.published}/>! published {renderRelativeDate(data.lastNote.published)}!
</p> </p>
<div class="mt-0 p-1.5 border-4 border-double bg-ralsei-black min-w-full max-w-[40ch]"> <div class="mt-0 p-1.5 border-4 border-double bg-ralsei-black min-w-full max-w-[40ch]">
<Note note={data.lastNote} onlyContent/> <Note note={data.lastNote} onlyContent/>

View File

@ -2,8 +2,6 @@ import adapter from 'svelte-adapter-bun';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { mdsvex } from 'mdsvex' import { mdsvex } from 'mdsvex'
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
import rehypeSlug from 'rehype-slug'
import * as toml from "@std/toml"; import * as toml from "@std/toml";
@ -33,10 +31,6 @@ const config = {
} }
}, },
}, },
rehypePlugins: [
rehypeSlug,
rehypeAutolinkHeadings,
],
smartypants: { smartypants: {
dashes: 'oldschool', dashes: 'oldschool',
quotes: true, quotes: true,