refactor: format stuffs fix warnings

This commit is contained in:
dusk 2025-04-02 07:47:53 +03:00
parent 25ee5d47e3
commit 081e709ba5
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
7 changed files with 127 additions and 93 deletions

@ -1,34 +1,37 @@
import convertDate from "$lib/convertDate";
import convertDate from '$lib/convertDate';
export interface PostData {
path: string,
published: string,
metadata: Record<string, string>,
path: string;
published: string;
metadata: Record<string, string>;
}
const allPostFiles: Record<string, any> = import.meta.glob('./*/+page.md', { eager: true });
const allPosts: PostData[] = Object.entries(allPostFiles).map(([path, post]) => {
const postPath = path.slice(2, -8);
return {
metadata: post.metadata,
path: postPath,
published: convertDate(post.metadata.date)
};
}).map((post) => {
if (!("excerpt" in post.metadata)) {
post.metadata.excerpt = ""
}
return post;
}).toSorted((post, opost) => {
const date = new Date(post.metadata.date);
const odate = new Date(opost.metadata.date);
return odate.getTime() - date.getTime()
});
const allPosts: PostData[] = Object.entries(allPostFiles)
.map(([path, post]) => {
const postPath = path.slice(2, -8);
return {
metadata: post.metadata,
path: postPath,
published: convertDate(post.metadata.date)
};
})
.map((post) => {
if (!('excerpt' in post.metadata)) {
post.metadata.excerpt = '';
}
return post;
})
.toSorted((post, opost) => {
const date = new Date(post.metadata.date);
const odate = new Date(opost.metadata.date);
return odate.getTime() - date.getTime();
});
export const _allPosts = allPosts;
export async function load({}) {
export async function load() {
if (!allPosts.length) {
return { status: 404 };
}
return { posts: allPosts };
}
}

@ -15,22 +15,24 @@
<div class="mx-auto md:max-w-fit flex flex-col-reverse md:flex-row gap-y-4 gap-x-16">
<div class="flex flex-col gap-y-4">
{#each posts as post}
<Window title={post.metadata.title} iconUri='/icons/entry.webp'>
<a
href="/entries/{post.path}"
title="cd /entries/{post.path}"
data-sveltekit-preload-data="off"
>
<div class="flex flex-col prose prose-ralsei leading-5">
<ul>
<li>published on: <time datetime="{post.metadata.date} 00:00:00">{post.published}</time></li>
<li class="max-w-[34ch] text-wrap">excerpt: {post.metadata.excerpt}</li>
</ul>
<strong class="place-self-end text-ralsei-green-light"> read more... </strong>
</div>
</a>
</Window>
<Window title={post.metadata.title} iconUri="/icons/entry.webp">
<a
href="/entries/{post.path}"
title="cd /entries/{post.path}"
data-sveltekit-preload-data="off"
>
<div class="flex flex-col prose prose-ralsei leading-5">
<ul>
<li>
published on: <time datetime="{post.metadata.date} 00:00:00">{post.published}</time>
</li>
<li class="max-w-[34ch] text-wrap">excerpt: {post.metadata.excerpt}</li>
</ul>
<strong class="place-self-end text-ralsei-green-light"> read more... </strong>
</div>
</a>
</Window>
{/each}
</div>
<LogPage {data}/>
<LogPage {data} />
</div>

@ -3,15 +3,13 @@ import { _allPosts, type PostData } from '../+layout.server.ts';
const entriesUrl = `${PUBLIC_BASE_URL}/entries`;
export const GET = async ({ }) => {
return new Response(
render(_allPosts),
{
headers: {
'content-type': 'application/xml',
'cache-control': 'no-store',
}
})
export const GET = async () => {
return new Response(render(_allPosts), {
headers: {
'content-type': 'application/xml',
'cache-control': 'no-store'
}
});
};
const render = (posts: PostData[]) => `<?xml version="1.0" encoding="UTF-8" ?>
@ -21,13 +19,17 @@ const render = (posts: PostData[]) => `<?xml version="1.0" encoding="UTF-8" ?>
<title>dusk's posts (@gaze.systems)</title>
<link>${entriesUrl}</link>
<description>posts from my website</description>
${posts.map((post) => `<item>
${posts
.map(
(post) => `<item>
<guid>${entriesUrl}/${post.path}</guid>
<title>${post.metadata.title}</title>
<link>${entriesUrl}/${post.path}</link>
<description>${post.metadata.excerpt}</description>
<pubDate>${new Date(post.metadata.date).toUTCString()}</pubDate>
</item>`).join('')}
</item>`
)
.join('')}
</channel>
</rss>
`;
`;

@ -1,12 +1,12 @@
import images from './images.json'
import images from './images.json';
export async function load({}) {
export async function load() {
return {
images: images.map((id) => {
return {
og: `https://res.cloudinary.com/dgtwf7mar/image/upload/v1/${id}`,
thumb: `https://res.cloudinary.com/dgtwf7mar/image/upload/c_fill,w_480,h_480,g_center/c_limit,w_480/f_auto/q_auto/v1/${id}`,
}
})
};
}
images: images.map((id) => {
return {
og: `https://res.cloudinary.com/dgtwf7mar/image/upload/v1/${id}`,
thumb: `https://res.cloudinary.com/dgtwf7mar/image/upload/c_fill,w_480,h_480,g_center/c_limit,w_480/f_auto/q_auto/v1/${id}`
};
})
};
}

@ -1,12 +1,12 @@
import { getLastPosts } from '$lib/bluesky.js';
import { noteFromBskyPost } from '../../components/note.svelte';
export const load = async ({ }) => {
return _load()
}
export const load = async () => {
return _load();
};
export const _load = async () => {
return {
feedPosts: getLastPosts().map(noteFromBskyPost),
}
}
return {
feedPosts: getLastPosts().map(noteFromBskyPost)
};
};

@ -1,37 +1,64 @@
<script lang="ts">
import Window from '../../components/window.svelte';
import Token from '../../components/token.svelte';
import Note from '../../components/note.svelte';
import Token from '../../components/token.svelte';
import Note, { type NoteData } from '../../components/note.svelte';
interface Props {
data: any;
}
interface Props {
data: {
feedPosts: NoteData[];
};
}
let { data }: Props = $props();
let { data }: Props = $props();
</script>
<Window title="terminal" removePadding>
<div
class="
<div
class="
prose prose-ralsei
prose-pre:rounded-none prose-pre:!m-0 prose-pre:!p-2
prose-pre:!bg-ralsei-black prose-code:!bg-ralsei-black
"
>
<pre class="language-bash"><code class="language-bash"><nobr>
<Token v="[" punct/>gazesystems <Token v="/" keywd/><Token v="]$" punct/> <Token v="source" funct/> <Token v="scripts/log.nu" />
<br>
<Token v="[" punct/>gazesystems <Token v="/" keywd/><Token v="]$" punct/> <Token v="let" funct/> <Token v="entries"/> <Token v="=" punct/> <Token v="(" punct/><Token v="ls" funct/> <Token v="logs" /> <Token v="|" punct/> <Token v="reverse" funct/> <Token v="|" punct/> <Token v="take" funct/> <Token v="13"/><Token v=")" punct/>
<br>
<Token v="[" punct/>gazesystems <Token v="/" keywd/><Token v="]$" punct/> <Token v="$entries" /> <Token v="|" punct/> <Token v="each" funct/> <Token v="&#123;" punct/><Token v="|" punct/><Token v="file"/><Token v="|" punct/> <Token v="render" funct/> <Token v="(" punct/><Token v="open" funct/> <Token v="$file.name" /><Token v=")" punct/><Token v="&#125;" punct/>
<br>
<br>
>
<pre class="language-bash"><code class="language-bash"
><nobr>
<Token v="[" punct />gazesystems <Token v="/" keywd /><Token v="]$" punct /> <Token
v="source"
funct
/> <Token v="scripts/log.nu" />
<br />
<Token v="[" punct />gazesystems <Token v="/" keywd /><Token v="]$" punct /> <Token
v="let"
funct
/> <Token v="entries" /> <Token v="=" punct /> <Token v="(" punct /><Token
v="ls"
funct
/> <Token v="logs" /> <Token v="|" punct /> <Token v="reverse" funct /> <Token
v="|"
punct
/> <Token v="take" funct /> <Token v="13" /><Token v=")" punct />
<br />
<Token v="[" punct />gazesystems <Token v="/" keywd /><Token v="]$" punct /> <Token
v="$entries"
/> <Token v="|" punct /> <Token v="each" funct /> <Token v="&#123;" punct /><Token
v="|"
punct
/><Token v="file" /><Token v="|" punct /> <Token v="render" funct /> <Token
v="("
punct
/><Token v="open" funct /> <Token v="$file.name" /><Token v=")" punct /><Token
v="&#125;"
punct
/>
<br />
<br />
{#each data.feedPosts as note, index}
<Note {note}/>
<Note {note} />
{#if index < data.feedPosts.length - 1}
<div class="mt-3"></div>
{/if}
{/each}
</nobr></code></pre>
</div>
<div class="mt-3"></div>
{/if}
{/each}
</nobr></code
></pre>
</div>
</Window>

@ -1,5 +1,5 @@
import { redirect } from '@sveltejs/kit';
export const GET = async ({ }) => {
redirect(301, "https://bsky.app/profile/did:plc:dfl62fgb7wtjj3fcbb72naae/rss")
export const GET = async () => {
redirect(301, 'https://bsky.app/profile/did:plc:dfl62fgb7wtjj3fcbb72naae/rss');
};