Skip to content

Commit

Permalink
🐛 Fix Error
Browse files Browse the repository at this point in the history
  • Loading branch information
piro-hiroki committed Mar 9, 2024
1 parent 0e16400 commit 94dbf50
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { CollectionEntry } from "astro:content";

export interface Props {
href?: string;
frontmatter: CollectionEntry<"blog">["data"];
frontmatter: CollectionEntry<"blog" | "policies">["data"];
secHeading?: boolean;
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { CollectionEntry } from "astro:content";
export type SearchItem = {
title: string;
description: string;
data: CollectionEntry<"blog">["data"];
data: CollectionEntry<"blog" | "policies">["data"];
slug: string;
};

Expand Down Expand Up @@ -83,9 +83,9 @@ export default function SearchBar({ searchList }: Props) {
<span className="sr-only">Search</span>
</span>
<input
className="block w-full rounded border border-skin-fill
className="block w-full rounded border border-skin-fill
border-opacity-40 bg-skin-fill py-3 pl-10
pr-3 placeholder:italic placeholder:text-opacity-75
pr-3 placeholder:italic placeholder:text-opacity-75
focus:border-skin-accent focus:outline-none"
placeholder="Search for anything..."
type="text"
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Policies.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SITE } from "@config";
export interface Props {
currentPage: number;
totalPages: number;
paginatedPosts: CollectionEntry<"blog">[];
paginatedPosts: CollectionEntry<"blog" | "policies">[];
}
const { currentPage, totalPages, paginatedPosts } = Astro.props;
Expand Down
5 changes: 1 addition & 4 deletions src/layouts/PolicyDetails.astro
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
---
import Layout from "@layouts/Layout.astro";
import Footer from "@components/Footer.astro";
import Tag from "@components/Tag.astro";
import Datetime from "@components/Datetime";
import type { CollectionEntry } from "astro:content";
import { slugifyStr } from "@utils/slugify";
import ShareLinks from "@components/ShareLinks.astro";
import { SITE } from "@config";
export interface Props {
post: CollectionEntry<"blog">;
post: CollectionEntry<"blog" | "policies">;
}
const { post } = Astro.props;
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/PostDetails.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ShareLinks from "@components/ShareLinks.astro";
import { SITE } from "@config";
export interface Props {
post: CollectionEntry<"blog">;
post: CollectionEntry<"blog" | "policies">;
}
const { post } = Astro.props;
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Posts.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SITE } from "@config";
export interface Props {
currentPage: number;
totalPages: number;
paginatedPosts: CollectionEntry<"blog">[];
paginatedPosts: CollectionEntry<"blog" | "policies">[];
}
const { currentPage, totalPages, paginatedPosts } = Astro.props;
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/TagPosts.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SITE } from "@config";
export interface Props {
currentPage: number;
totalPages: number;
paginatedPosts: CollectionEntry<"blog">[];
paginatedPosts: CollectionEntry<"blog" | "policies">[];
tag: string;
tagName: string;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/[slug]/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import getPageNumbers from "@utils/getPageNumbers";
import getPagination from "@utils/getPagination";
export interface Props {
post: CollectionEntry<"blog">;
post: CollectionEntry<"blog" | "policies">;
}
export async function getStaticPaths() {
Expand Down
9 changes: 6 additions & 3 deletions src/pages/posts/[slug]/index.png.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export async function getStaticPaths() {
}

export const GET: APIRoute = async ({ props }) =>
new Response(await generateOgImageForPost(props as CollectionEntry<"blog">), {
headers: { "Content-Type": "image/png" },
});
new Response(
await generateOgImageForPost(props as CollectionEntry<"blog" | "policies">),
{
headers: { "Content-Type": "image/png" },
}
);
9 changes: 6 additions & 3 deletions src/pages/privacy-policies/[slug]/index.png.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export async function getStaticPaths() {
}

export const GET: APIRoute = async ({ props }) =>
new Response(await generateOgImageForPost(props as CollectionEntry<"blog">), {
headers: { "Content-Type": "image/png" },
});
new Response(
await generateOgImageForPost(props as CollectionEntry<"blog" | "policies">),
{
headers: { "Content-Type": "image/png" },
}
);
2 changes: 1 addition & 1 deletion src/pages/tags/[tag]/[page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import getPageNumbers from "@utils/getPageNumbers";
import getPagination from "@utils/getPagination";
export interface Props {
post: CollectionEntry<"blog">;
post: CollectionEntry<"blog" | "policies">;
tag: string;
tagName: string;
}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/generateOgImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function svgBufferToPngBuffer(svg: string) {
return pngData.asPng();
}

export async function generateOgImageForPost(post: CollectionEntry<"blog">) {
export async function generateOgImageForPost(
post: CollectionEntry<"blog" | "policies">
) {
const svg = await satori(postOgImage(post), options);
return svgBufferToPngBuffer(svg);
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/getPostsByTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import type { CollectionEntry } from "astro:content";
import getSortedPosts from "./getSortedPosts";
import { slugifyAll } from "./slugify";

const getPostsByTag = (posts: CollectionEntry<"blog">[], tag: string) =>
const getPostsByTag = (
posts: CollectionEntry<"blog" | "policies">[],
tag: string
) =>
getSortedPosts(
posts.filter(post => slugifyAll(post.data.tags).includes(tag))
);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getSortedPosts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CollectionEntry } from "astro:content";
import postFilter from "./postFilter";

const getSortedPosts = (posts: CollectionEntry<"blog">[]) => {
const getSortedPosts = (posts: CollectionEntry<"blog" | "policies">[]) => {
if (!posts) return [];

return posts
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getUniqueTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Tag {
tagName: string;
}

const getUniqueTags = (posts: CollectionEntry<"blog">[]) => {
const getUniqueTags = (posts: CollectionEntry<"blog" | "policies">[]) => {
const tags: Tag[] = posts
.filter(postFilter)
.flatMap(post => post.data.tags)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/og-templates/post.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SITE } from "@config";
import type { CollectionEntry } from "astro:content";

export default (post: CollectionEntry<"blog">) => {
export default (post: CollectionEntry<"blog" | "policies">) => {
return (
<div
style={{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/postFilter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SITE } from "@config";
import type { CollectionEntry } from "astro:content";

const postFilter = ({ data }: CollectionEntry<"blog">) => {
const postFilter = ({ data }: CollectionEntry<"blog" | "policies">) => {
const isPublishTimePassed =
Date.now() >
new Date(data.pubDatetime).getTime() - SITE.scheduledPostMargin;
Expand Down

0 comments on commit 94dbf50

Please sign in to comment.