mirror of
https://github.com/10h30/blog-balodeplao.git
synced 2026-05-12 15:21:15 +09:00
feat: add TypeScript interfaces for blog, category, destination, and tag pages
This commit is contained in:
@@ -7,7 +7,11 @@ import Destinations from "@/components/ui/Destinations.astro";
|
||||
import { toR2Url } from "@/utils/r2";
|
||||
import Picture from "@/components/ui/Picture.astro";
|
||||
|
||||
import { getCollection, render } from "astro:content";
|
||||
import { getCollection, render, type CollectionEntry } from "astro:content";
|
||||
|
||||
interface Props {
|
||||
post: CollectionEntry<"blog">;
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blog = await getCollection("blog");
|
||||
@@ -17,7 +21,7 @@ export async function getStaticPaths() {
|
||||
}));
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
const { post } = Astro.props as Props;
|
||||
const { Content, remarkPluginFrontmatter } = await render(post);
|
||||
const {
|
||||
title,
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import Headline from "@/components/ui/Headline.astro";
|
||||
import Pagination from "@/components/ui/Pagination.astro";
|
||||
import PostItem from "@/components/blog/PostItem.astro";
|
||||
import { buildPaginatedPaths } from "@/utils/paginate";
|
||||
|
||||
interface Props {
|
||||
page: {
|
||||
data: CollectionEntry<"blog">[];
|
||||
total: number;
|
||||
currentPage: number;
|
||||
lastPage: number;
|
||||
url: { prev?: string; next?: string };
|
||||
};
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection("blog");
|
||||
const sortedPosts = blogEntries
|
||||
@@ -20,7 +31,7 @@ export async function getStaticPaths() {
|
||||
);
|
||||
}
|
||||
|
||||
const { page } = Astro.props;
|
||||
const { page } = Astro.props as Props;
|
||||
const blog = page.data;
|
||||
|
||||
const metadata = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import Headline from "@/components/ui/Headline.astro";
|
||||
import PostItem from "@/components/blog/PostItem.astro";
|
||||
import Pagination from "@/components/ui/Pagination.astro";
|
||||
@@ -11,6 +12,16 @@ import {
|
||||
} from "@/utils/taxonomy";
|
||||
import { buildPaginatedPaths } from "@/utils/paginate";
|
||||
|
||||
interface Props {
|
||||
cat: TaxonomyItem;
|
||||
posts: CollectionEntry<"blog">[];
|
||||
currentPage: number;
|
||||
lastPage: number;
|
||||
total: number;
|
||||
prevUrl?: string;
|
||||
nextUrl?: string;
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const allPosts = await getCollection("blog");
|
||||
const posts = allPosts.filter((post) => post.data && post.data.pubDate);
|
||||
@@ -48,7 +59,7 @@ export async function getStaticPaths() {
|
||||
}
|
||||
|
||||
const { cat, posts, currentPage, lastPage, total, prevUrl, nextUrl } =
|
||||
Astro.props;
|
||||
Astro.props as Props;
|
||||
|
||||
const page = {
|
||||
currentPage,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import Headline from "@/components/ui/Headline.astro";
|
||||
import PostItem from "@/components/blog/PostItem.astro";
|
||||
import Pagination from "@/components/ui/Pagination.astro";
|
||||
@@ -11,6 +12,16 @@ import {
|
||||
} from "@/utils/taxonomy";
|
||||
import { buildPaginatedPaths } from "@/utils/paginate";
|
||||
|
||||
interface Props {
|
||||
dest: TaxonomyItem;
|
||||
posts: CollectionEntry<"blog">[];
|
||||
currentPage: number;
|
||||
lastPage: number;
|
||||
total: number;
|
||||
prevUrl?: string;
|
||||
nextUrl?: string;
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const allPosts = await getCollection("blog");
|
||||
const posts = allPosts.filter((post) => post.data && post.data.pubDate);
|
||||
@@ -48,7 +59,7 @@ export async function getStaticPaths() {
|
||||
}
|
||||
|
||||
const { dest, posts, currentPage, lastPage, total, prevUrl, nextUrl } =
|
||||
Astro.props;
|
||||
Astro.props as Props;
|
||||
|
||||
const page = {
|
||||
currentPage,
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import Headline from "@/components/ui/Headline.astro";
|
||||
import PostItem from "@/components/blog/PostItem.astro";
|
||||
import Pagination from "@/components/ui/Pagination.astro";
|
||||
import { getTaxonomyMap } from "@/utils/taxonomy";
|
||||
import { buildPaginatedPaths } from "@/utils/paginate";
|
||||
|
||||
interface Props {
|
||||
page: {
|
||||
data: CollectionEntry<"blog">[];
|
||||
total: number;
|
||||
currentPage: number;
|
||||
lastPage: number;
|
||||
url: { prev?: string; next?: string };
|
||||
};
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const allPosts = await getCollection("blog");
|
||||
const posts = allPosts.filter((post) => post.data && post.data.pubDate);
|
||||
@@ -30,7 +41,7 @@ export async function getStaticPaths() {
|
||||
});
|
||||
}
|
||||
|
||||
const { page } = Astro.props;
|
||||
const { page } = Astro.props as Props;
|
||||
const { tag } = Astro.params;
|
||||
|
||||
const tagInfo = getTaxonomyMap("tag").get(tag!);
|
||||
|
||||
Reference in New Issue
Block a user