Skip to content

Commit

Permalink
chore: Add type for entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Oct 5, 2023
1 parent 1cd6e29 commit 8c9ca97
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/feedview/entries/Entries.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

<script lang="ts">
import EntriesByYear from "./EntriesByYear.svelte";
import type { Entry, EntriesByYearRecord } from "./entrytypes";
export let entries: any = [];
const entriesByYear = entries.reduce((acc: any, entry: any) => {
export let entries: Entry[] = [];
const entriesByYear = entries.reduce((acc: EntriesByYearRecord, entry: Entry) => {
const published = new Date(entry.published);
if (!acc[published.getFullYear()]) acc[published.getFullYear()] = [];
acc[published.getFullYear()].push(entry);
Expand Down
26 changes: 26 additions & 0 deletions src/lib/feedview/entries/entrytypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export type Link = {
rel: string;
href: string;
};

export type Content = {
type: string;
src: string;
};

export type Format = {
schema: string;
version: string;
};

export type Entry = {
id: string;
title: string;
link: Link[];
published: string;
updated: string;
content: Content;
format: Format;
};

export type EntriesByYear = Record<string, Entry[]>;

0 comments on commit 8c9ca97

Please sign in to comment.