Skip to content

Commit b7a6cd4

Browse files
committed
chore: check
1 parent a640d6f commit b7a6cd4

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

src/components/ArchivePanel.svelte

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,13 @@ import { onMount } from "svelte";
44
import I18nKey from "../i18n/i18nKey";
55
import { i18n } from "../i18n/translation";
66
import { getPostUrlBySlug } from "../utils/url-utils";
7+
import type { PostForList } from "../utils/content-utils";
78
8-
export let tags: string[];
9-
export let categories: string[];
10-
export let sortedPosts: Post[] = [];
11-
12-
const params = new URLSearchParams(window.location.search);
13-
tags = params.has("tag") ? params.getAll("tag") : [];
14-
categories = params.has("category") ? params.getAll("category") : [];
15-
const uncategorized = params.get("uncategorized");
16-
17-
interface Post {
18-
slug: string;
19-
data: {
20-
title: string;
21-
tags: string[];
22-
category?: string;
23-
published: Date;
24-
};
25-
}
9+
export let tags: string[] = [];
10+
export let categories: string[] = [];
11+
export let sortedPosts: PostForList[] = [];
12+
13+
type Post = PostForList;
2614
2715
interface Group {
2816
year: number;
@@ -42,6 +30,14 @@ function formatTag(tagList: string[]) {
4230
}
4331
4432
onMount(async () => {
33+
const params = new URLSearchParams(window.location.search);
34+
const urlTags = params.has("tag") ? params.getAll("tag") : [];
35+
const urlCategories = params.has("category") ? params.getAll("category") : [];
36+
const uncategorized = params.get("uncategorized");
37+
38+
if (urlTags.length > 0) tags = urlTags;
39+
if (urlCategories.length > 0) categories = urlCategories;
40+
4541
let filteredPosts: Post[] = sortedPosts;
4642
4743
if (tags.length > 0) {

0 commit comments

Comments
 (0)