hd-garden 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,6 @@
2
2
 
3
3
  import Link from "next/link";
4
4
  import { useSearchParams } from "next/navigation";
5
- import { useEffect, useState } from "react";
6
5
  import { ArrowLeft, ArrowRight, PushPin } from "@phosphor-icons/react";
7
6
  import { formatDate, postHref, posts, topics } from "../lib/content";
8
7
  import { ContentEmptyState } from "./ContentEmptyState";
@@ -19,19 +18,13 @@ export const archiveHref = (topic?: string, page?: number) => {
19
18
 
20
19
  export function BlogArchive() {
21
20
  const searchParams = useSearchParams();
22
- const [ready, setReady] = useState(false);
23
-
24
- useEffect(() => {
25
- setReady(true);
26
- }, []);
27
-
28
- const requestedTopic = ready ? (searchParams.get("topic") ?? "") : "";
21
+ const requestedTopic = searchParams.get("topic") ?? "";
29
22
  const selectedTopic = topics.includes(requestedTopic) ? requestedTopic : undefined;
30
23
  const filteredPosts = selectedTopic
31
24
  ? posts.filter((post) => post.topic === selectedTopic)
32
25
  : posts;
33
26
  const pageCount = Math.max(1, Math.ceil(filteredPosts.length / pageSize));
34
- const parsedPage = Number.parseInt((ready ? searchParams.get("page") : null) ?? "1", 10);
27
+ const parsedPage = Number.parseInt(searchParams.get("page") ?? "1", 10);
35
28
  const currentPage = Math.min(
36
29
  pageCount,
37
30
  Math.max(1, Number.isFinite(parsedPage) ? parsedPage : 1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hd-garden",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "private": false,
5
5
  "description": "用 Markdown 写作、用 GitHub Pages 发布的个人博客引擎。",
6
6
  "license": "MIT",
@@ -14,6 +14,6 @@
14
14
  "pages:prepare": "garden pages:prepare"
15
15
  },
16
16
  "dependencies": {
17
- "hd-garden": "^0.3.1"
17
+ "hd-garden": "^0.3.2",
18
18
  }
19
19
  }