Fix astro check errors on strict typescript, issue #293
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import type { PaginateFunction } from 'astro';
|
||||
import { getCollection } from 'astro:content';
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import type { Post } from '~/types';
|
||||
@ -162,7 +163,7 @@ export const findLatestPosts = async ({ count }: { count?: number }): Promise<Ar
|
||||
};
|
||||
|
||||
/** */
|
||||
export const getStaticPathsBlogList = async ({ paginate }) => {
|
||||
export const getStaticPathsBlogList = async ({ paginate }: { paginate: PaginateFunction }) => {
|
||||
if (!isBlogEnabled || !isBlogListRouteEnabled) return [];
|
||||
return paginate(await fetchPosts(), {
|
||||
params: { blog: BLOG_BASE || undefined },
|
||||
@ -182,16 +183,16 @@ export const getStaticPathsBlogPost = async () => {
|
||||
};
|
||||
|
||||
/** */
|
||||
export const getStaticPathsBlogCategory = async ({ paginate }) => {
|
||||
export const getStaticPathsBlogCategory = async ({ paginate }: { paginate: PaginateFunction }) => {
|
||||
if (!isBlogEnabled || !isBlogCategoryRouteEnabled) return [];
|
||||
|
||||
const posts = await fetchPosts();
|
||||
const categories = new Set();
|
||||
const categories = new Set<string>();
|
||||
posts.map((post) => {
|
||||
typeof post.category === 'string' && categories.add(post.category.toLowerCase());
|
||||
});
|
||||
|
||||
return Array.from(categories).flatMap((category: string) =>
|
||||
return Array.from(categories).flatMap((category) =>
|
||||
paginate(
|
||||
posts.filter((post) => typeof post.category === 'string' && category === post.category.toLowerCase()),
|
||||
{
|
||||
@ -204,16 +205,16 @@ export const getStaticPathsBlogCategory = async ({ paginate }) => {
|
||||
};
|
||||
|
||||
/** */
|
||||
export const getStaticPathsBlogTag = async ({ paginate }) => {
|
||||
export const getStaticPathsBlogTag = async ({ paginate }: { paginate: PaginateFunction }) => {
|
||||
if (!isBlogEnabled || !isBlogTagRouteEnabled) return [];
|
||||
|
||||
const posts = await fetchPosts();
|
||||
const tags = new Set();
|
||||
const tags = new Set<string>();
|
||||
posts.map((post) => {
|
||||
Array.isArray(post.tags) && post.tags.map((tag) => tags.add(tag.toLowerCase()));
|
||||
});
|
||||
|
||||
return Array.from(tags).flatMap((tag: string) =>
|
||||
return Array.from(tags).flatMap((tag) =>
|
||||
paginate(
|
||||
posts.filter((post) => Array.isArray(post.tags) && post.tags.find((elem) => elem.toLowerCase() === tag)),
|
||||
{
|
||||
|
Reference in New Issue
Block a user