Fix astro check errors on strict typescript, issue #293
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
---
|
||||
import type { InferGetStaticPropsType, GetStaticPaths } from 'astro';
|
||||
|
||||
import Layout from '~/layouts/PageLayout.astro';
|
||||
import BlogList from '~/components/blog/List.astro';
|
||||
import Headline from '~/components/blog/Headline.astro';
|
||||
@@ -9,11 +11,13 @@ import { blogListRobots, getStaticPathsBlogList } from '~/utils/blog';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export async function getStaticPaths ({ paginate }) {
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
return await getStaticPathsBlogList({ paginate });
|
||||
}
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { page } = Astro.props;
|
||||
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
|
||||
|
||||
const { page } = Astro.props as Props;
|
||||
const currentPage = page.currentPage ?? 1;
|
||||
|
||||
// const allCategories = await findCategories();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
---
|
||||
import type { InferGetStaticPropsType, GetStaticPaths } from 'astro';
|
||||
import { blogCategoryRobots, getStaticPathsBlogCategory } from '~/utils/blog';
|
||||
|
||||
import Layout from '~/layouts/PageLayout.astro';
|
||||
@@ -8,11 +9,13 @@ import Pagination from '~/components/blog/Pagination.astro';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export async function getStaticPaths ({ paginate }) {
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
return await getStaticPathsBlogCategory({ paginate });
|
||||
}
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { page, category } = Astro.props;
|
||||
type Props = InferGetStaticPropsType<typeof getStaticPaths> & { category: string };
|
||||
|
||||
const { page, category } = Astro.props as Props;
|
||||
|
||||
const currentPage = page.currentPage ?? 1;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
---
|
||||
import type { InferGetStaticPropsType, GetStaticPaths } from 'astro';
|
||||
import { blogTagRobots, getStaticPathsBlogTag } from '~/utils/blog';
|
||||
|
||||
import Layout from '~/layouts/PageLayout.astro';
|
||||
@@ -8,11 +9,13 @@ import Pagination from '~/components/blog/Pagination.astro';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export async function getStaticPaths ({ paginate }) {
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
return await getStaticPathsBlogTag({ paginate });
|
||||
}
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { page, tag } = Astro.props;
|
||||
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
|
||||
|
||||
const { page, tag } = Astro.props as Props;
|
||||
|
||||
const currentPage = page.currentPage ?? 1;
|
||||
|
||||
|
@@ -1,4 +1,6 @@
|
||||
---
|
||||
import type { InferGetStaticPropsType, GetStaticPaths } from 'astro';
|
||||
|
||||
import merge from 'lodash.merge';
|
||||
import type { ImageMetadata } from 'astro';
|
||||
import Layout from '~/layouts/PageLayout.astro';
|
||||
@@ -8,17 +10,20 @@ import ToBlogLink from '~/components/blog/ToBlogLink.astro';
|
||||
import { getCanonical, getPermalink } from '~/utils/permalinks';
|
||||
import { getStaticPathsBlogPost, blogPostRobots } from '~/utils/blog';
|
||||
import { findImage } from '~/utils/images';
|
||||
import type { MetaData } from '~/types';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export async function getStaticPaths () {
|
||||
export const getStaticPaths = (async () => {
|
||||
return await getStaticPathsBlogPost();
|
||||
}
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { post } = Astro.props;
|
||||
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
|
||||
|
||||
const { post } = Astro.props as Props;
|
||||
|
||||
const url = getCanonical(getPermalink(post.permalink, 'post'));
|
||||
const image = (await findImage(post.image)) as ImageMetadata | undefined;
|
||||
const image = (await findImage(post.image)) as ImageMetadata | string | undefined;
|
||||
|
||||
const metadata = merge(
|
||||
{
|
||||
@@ -30,11 +35,11 @@ const metadata = merge(
|
||||
},
|
||||
openGraph: {
|
||||
type: 'article',
|
||||
...(image ? { images: [{ url: image, width: image?.width, height: image?.height }] } : {}),
|
||||
...(image ? { images: [{ url: image, width: (image as ImageMetadata)?.width, height: (image as ImageMetadata)?.height }] } : {}),
|
||||
},
|
||||
},
|
||||
{ ...(post?.metadata ? { ...post.metadata, canonical: post.metadata?.canonical || url } : {}) }
|
||||
);
|
||||
) as MetaData;
|
||||
---
|
||||
|
||||
<Layout metadata={metadata}>
|
||||
|
Reference in New Issue
Block a user