Skip to content

Commit

Permalink
Move Hacker News types
Browse files Browse the repository at this point in the history
  • Loading branch information
jonamil committed Aug 11, 2024
1 parent 9bf4083 commit 43a1d37
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 44 deletions.
1 change: 0 additions & 1 deletion src/components/CommentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
import DOMPurify from 'dompurify';
import smartquotes from 'smartquotes-ts';
import { formatNumberWithLabel, formatAbsoluteTimestamp } from '@/utils/formatting';
import type { HackerNewsItem } from '@/types';
const content = useContentStore();
const router = useRouter();
Expand Down
1 change: 0 additions & 1 deletion src/components/PostsListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
<script setup lang="ts">
import smartquotes from 'smartquotes-ts';
import { formatNumber, formatAbsoluteTimestamp, avoidShortWidows } from '@/utils/formatting';
import type { HackerNewsItem } from '@/types';
const view = useViewStore();
Expand Down
1 change: 0 additions & 1 deletion src/components/TheCommentsColumnBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@

<script setup lang="ts">
import scrollIntoView from 'smooth-scroll-into-view-if-needed';
import type { HackerNewsItem } from '@/types';
const view = useViewStore();
const content = useContentStore();
Expand Down
2 changes: 0 additions & 2 deletions src/stores/content.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { HackerNewsCategory, HackerNewsItemData, HackerNewsItem } from '@/types';

export const useContentStore = defineStore('content', () => {
const categoryNames: { [key in HackerNewsCategory]: string } = {
top: 'Top Stories',
Expand Down
36 changes: 0 additions & 36 deletions src/types.ts

This file was deleted.

40 changes: 40 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export {};

declare global {
type HackerNewsCategory = 'top' | 'new' | 'best' | 'ask' | 'show';

interface HackerNewsItemData {
id: number;
deleted?: boolean;
type?: string;
by?: string;
time?: number;
text?: string;
dead?: boolean;
parent?: number;
poll?: number;
kids?: number[];
url?: string;
score?: number;
title?: string;
parts?: number[];
descendants?: number;
}

interface HackerNewsItem extends Omit<HackerNewsItemData, 'url'> {
url?: {
hostname: string;
pathname: string;
href: string;
search: string;
};
}

interface HackerNewsUser {
id: string;
created: number;
karma: number;
about?: string;
submitted?: number[];
}
}
2 changes: 0 additions & 2 deletions src/utils/urls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { HackerNewsCategory } from '@/types';

const apiBaseUrl = 'https://hacker-news.firebaseio.com/v0/';

export function apiCategoryUrl(category: HackerNewsCategory) {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "auto-imports.d.ts", "components.d.ts", "src/**/*", "src/**/*.vue"],
"include": ["env.d.ts", "auto-imports.d.ts", "components.d.ts", "src/*.vue", "src/**/*"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
Expand Down

1 comment on commit 43a1d37

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for hackernews-dot-cool ready!

✅ Preview
https://hackernews-dot-cool-oeaiqotlv-jonamil-56ba8df7.vercel.app

Built with commit 43a1d37.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.