Fix astro check errors on strict typescript, issue #293

This commit is contained in:
prototypa
2023-12-02 09:09:13 -05:00
parent cf40b9d093
commit 788acd9321
7 changed files with 42 additions and 26 deletions

View File

@ -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)),
{