Skip to content

Commit

Permalink
feat: Remove ogp image generator (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicstone committed Mar 3, 2024
1 parent 56348a7 commit 07e29da
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 542 deletions.
25 changes: 0 additions & 25 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import path from "path";

import { formatInTimeZone } from "date-fns-tz";

import { createOgpImage } from "./src/utils/createOgpImage";
import { fetchLaprasActivity } from "./src/utils/fetchLaprasActivity";
import { isDefined } from "./src/utils/typeguard";

Expand Down Expand Up @@ -129,7 +128,6 @@ export const createPages: GatsbyNode["createPages"] = async ({

/**
* Add Search nodes
* Create OGP images
*/
export const createPagesStatefully: GatsbyNode["createPagesStatefully"] =
async ({ graphql, reporter, actions, createNodeId, createContentDigest }) => {
Expand Down Expand Up @@ -257,29 +255,6 @@ export const createPagesStatefully: GatsbyNode["createPagesStatefully"] =
reporter.success(
`onCreatePagesStatefully: Created ${timelineList.length} search nodes`,
);

/**
* Create OGP images
*/

const blogPostList = result?.data?.blogPosts?.nodes.map((node) => ({
title: node.frontmatter.title,
slug: node.frontmatter.slug,
excerpt: node.frontmatter.excerpt,
}));

if (!isDefined(blogPostList)) throw new Error("blogPostList is undefined");

for (const blogPost of blogPostList) {
await createOgpImage({
title: blogPost.title,
slug: blogPost.slug,
});
}

reporter.success(
`onCreatePagesStatefully: Created ${blogPostList.length} blog ogp images`,
);
};

/**
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"@types/react-dom": "18.2.19",
"@typescript-eslint/eslint-plugin": "7.0.2",
"@typescript-eslint/parser": "7.0.2",
"canvas": "2.11.2",
"dotenv": "16.4.5",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/HeadTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const HeadTemplate = (props: {
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={image} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@bicstone_me" />
<meta name="twitter:creator" content="@bicstone_me" />

Expand Down
5 changes: 1 addition & 4 deletions src/pages/outputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ export const Head: HeadFC<OutputsPageQuery> = ({ location, data }) => {
...outputsItems.map((item) => ({
"@type": "BlogPosting",
headline: item.title,
image:
item.__typename === "Mdx"
? `${SITE_METADATA.siteUrl}/ogp/${item.slug}.png`
: SITE_METADATA.logoImage,
image: SITE_METADATA.logoImage,
datePublished: item.date,
author: {
"@type": "Person",
Expand Down
6 changes: 2 additions & 4 deletions src/templates/BlogPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Head: HeadFC<BlogPostTemplateQuery> = ({ location, data }) => {
location={location}
title={title}
description={post.frontmatter.excerpt}
image={`${SITE_METADATA.siteUrl}/ogp/${post.frontmatter.slug}.png`}
image={SITE_METADATA.logoImage}
imageAlt={SITE_METADATA.title}
type="article"
/>
Expand All @@ -85,9 +85,7 @@ export const Head: HeadFC<BlogPostTemplateQuery> = ({ location, data }) => {
"@context": "https://schema.org",
"@type": "BlogPosting",
headline: title,
image: [
`${SITE_METADATA.siteUrl}/ogp/${post.frontmatter.slug}.png`,
],
image: [SITE_METADATA.logoImage],
datePublished: post.frontmatter.date,
dateModified: post.frontmatter.updateDate,
dateCreated: post.frontmatter.date,
Expand Down
Binary file removed src/utils/createOgpImage/UDGothic/Bold.ttf
Binary file not shown.
93 changes: 0 additions & 93 deletions src/utils/createOgpImage/UDGothic/LICENSE

This file was deleted.

Binary file removed src/utils/createOgpImage/UDGothic/Regular.ttf
Binary file not shown.
Binary file removed src/utils/createOgpImage/background.png
Binary file not shown.
89 changes: 0 additions & 89 deletions src/utils/createOgpImage/calculateTextPositionIntoRectangle.ts

This file was deleted.

Loading

0 comments on commit 07e29da

Please sign in to comment.