Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Sep 15, 2022
1 parent ac5a348 commit 5031fd8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
24 changes: 24 additions & 0 deletions src/lib/public/blog/types.ts
@@ -0,0 +1,24 @@
export interface BlogOutput {
labels: string[];
posts: Newsletter[];
}

export interface Newsletter {
id: number;
url: string;
discussionUrl: string;
title: string;
html: string;
createdAt: string | null;
lastEdited: string | null;
labels: string[];
author: {
displayname: string;
url: string;
picture: string;
};
}

export interface NewsletterFetchOptions {
labels: string[];
}
32 changes: 3 additions & 29 deletions src/lib/public/blog/utils.ts
@@ -1,8 +1,7 @@
import { DEBUG } from '$env/static/private';
import type { Officer } from '$lib/constants';
import { OFFICERS } from '$lib/constants';
import { discernLabels } from '$lib/common/utils';
import { SAMPLE_POSTS } from '../../server/blog/data';
// import type { Officer } from '$lib/constants';
// import { OFFICERS } from '$lib/server/';
import { SAMPLE_POSTS } from '$lib/server/blog/data';

interface WithLabels {
labels: string[];
Expand All @@ -16,31 +15,6 @@ export function discernLabels(posts: WithLabels[]): string[] {
return Array.from(labels).sort();
}

export interface BlogOutput {
labels: string[];
posts: Newsletter[];
}

export interface Newsletter {
id: number;
url: string;
discussionUrl: string;
title: string;
html: string;
createdAt: string | null;
lastEdited: string | null;
labels: string[];
author: {
displayname: string;
url: string;
picture: string;
};
}

export interface NewsletterFetchOptions {
labels: string[];
}

function getOfficerByGhUsername(ghUsername: string): Officer | null {
// get author by GitHub username
const officer = OFFICERS.find((o) => o.displayName !== undefined && o.displayName === ghUsername);
Expand Down
4 changes: 2 additions & 2 deletions src/routes/blog/[id].json/+page.ts
@@ -1,5 +1,5 @@
import type { RequestHandlerOutput, RequestEvent } from '@sveltejs/kit/types/internal';
import { fetchNewsletters, NewsletterFetchOptions } from './_query';
import type { RequestHandlerOutput, RequestEvent } from './$types';
import { fetchNewsletters, NewsletterFetchOptions } from '$lib/';

export async function get(event: RequestEvent): Promise<RequestHandlerOutput> {
const fetchOptions: NewsletterFetchOptions = { labels: [] };
Expand Down

0 comments on commit 5031fd8

Please sign in to comment.