implemented commit cards from rss repo rss feed.
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 1m28s

This commit is contained in:
ChrQR 2024-05-19 00:31:33 +02:00
parent 695f1009c2
commit 02cac45992
7 changed files with 74 additions and 20 deletions

11
package-lock.json generated
View File

@ -8,7 +8,8 @@
"name": "my-portfolio",
"version": "0.0.1",
"dependencies": {
"@sveltejs/adapter-vercel": "^5.3.0"
"@sveltejs/adapter-vercel": "^5.3.0",
"moment": "^2.30.1"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
@ -2596,6 +2597,14 @@
"node": ">=10"
}
},
"node_modules/moment": {
"version": "2.30.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
"engines": {
"node": "*"
}
},
"node_modules/mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",

View File

@ -27,6 +27,7 @@
},
"type": "module",
"dependencies": {
"@sveltejs/adapter-vercel": "^5.3.0"
"@sveltejs/adapter-vercel": "^5.3.0",
"moment": "^2.30.1"
}
}

22
src/lib/Commit.svelte Normal file
View File

@ -0,0 +1,22 @@
<script>
import moment from 'moment';
export let link;
export let title;
export let description;
export let published;
export let author;
const pubAgo = moment(published).fromNow();
</script>
<div
class="block p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700"
>
<div class="mb-2 text-2xl font-semibold tracking-tight text-gray-900 dark:text-white">
{@html title}
</div>
<div class="font-normal hover:text-slate-400">
{@html description}
</div>
<div>commited {pubAgo} by {@html author}</div>
<a class="hover:text-slate-400 underline" href={link}>view commit</a>
</div>

View File

@ -1,7 +1,9 @@
<script>
import { onMount } from 'svelte';
import Spinner from './Spinner.svelte';
import Commit from './Commit.svelte';
const url = 'https://gitea.rannes.dev/rannes.dev/my-portfolio.rss';
export let url;
let feed = null;
let error = null;
@ -33,18 +35,16 @@
});
</script>
<div class="my-4">
{#if error}
<p>Error: {error}</p>
{:else if !feed}
<p>Loading...</p>
<Spinner />
{:else}
<div>
{#each feed.slice(0, 5) as item}
<div>
<h3>{@html item.title}</h3>
<p>{@html item.description}</p>
<a href={item.link} target="_blank">Read more</a>
</div>
<div class="flex flex-col gap-2">
{#each feed.slice(0, 5) as commit}
<Commit {...commit} />
{/each}
</div>
{/if}
</div>

19
src/lib/Spinner.svelte Normal file
View File

@ -0,0 +1,19 @@
<div role="status">
<svg
aria-hidden="true"
class="inline w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-gray-600 dark:fill-gray-300"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span class="sr-only">Loading...</span>
</div>

View File

@ -79,5 +79,5 @@
<slot />
</div>
<footer class="mt-12">
<p class="text-sm text-gray-400">built and hosted by christian rannes 2024</p>
<p class="text-sm text-gray-400">built by christian rannes 2024</p>
</footer>

View File

@ -1,6 +1,8 @@
<script>
import { fade } from 'svelte/transition';
import RssFeed from '../../lib/RssFeed.svelte';
const projectRssUrl = 'https://gitea.rannes.dev/rannes.dev/my-portfolio.rss';
</script>
<div in:fade>
@ -19,5 +21,6 @@
>Read more about that here.</a
>
</p>
<RssFeed />
<h2 class="text-xl mt-4">Most recent commits</h2>
<RssFeed url={projectRssUrl} />
</div>