Skip to content

Commit

Permalink
feat: links and categories
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Oct 2, 2023
1 parent 74ac295 commit d007408
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/feedview/feed/Category.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts">
import KeyValue from "$lib/KeyValue.svelte";
import type { Category } from "./feedTypes";
export let categories: Category[] = [];
</script>

{#each categories as category}
<KeyValue keys={["scheme", "term"]} values={[category.scheme, category.term]} compact={true} />
{/each}
9 changes: 9 additions & 0 deletions src/lib/feedview/feed/Feed.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script lang="ts">
import Collapsible from "$lib/Collapsible.svelte";
import KeyValue from "$lib/KeyValue.svelte";
import { appStore } from "$lib/store";
import Category from "./Category.svelte";
import Links from "./Links.svelte";
$: feed = $appStore.currentFeed?.feed;
$: link = feed.link.find((l: any) => l.rel === "self");
</script>
Expand All @@ -13,4 +16,10 @@
compact={true}
/>
</div>
<Collapsible header="Links" level="3">
<Links links={feed.link} />
</Collapsible>
<Collapsible header="Category" level="3">
<Category categories={feed.category} />
</Collapsible>
{/if}
23 changes: 23 additions & 0 deletions src/lib/feedview/feed/Links.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts">
import type { Link } from "./feedTypes";
export let links: Link[] = [];
</script>

<table>
{#each links as link}
<tr>
<td class="key">{link.rel}: </td><td
><a id={crypto.randomUUID()} target="_blank" href={link.href}>{link.href}</a></td
>
</tr>
{/each}
</table>

<style>
.key {
width: 8vw;
}
td {
padding: 0.3rem;
}
</style>
18 changes: 18 additions & 0 deletions src/lib/feedview/feed/feedTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export type Category = {
scheme: string;
term: string;
};

export type Link = {
rel: string;
href: string;
};

export type Feed = {
id: string;
title: string;
link: Link[];
category: Category[];
updated: string;
entry: any;
};

0 comments on commit d007408

Please sign in to comment.