Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

OGP画像生成できなくなった問題修正 #41

Merged
merged 8 commits into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ module.exports = {
},
];
},
outputFileTracing: true,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"canvas": "^2.7.0",
"jsonld": "^5.2.0",
"moment": "^2.29.1",
"next": "11.1.1",
"next": "12.0.4",
"prismjs": "^1.23.0",
"react": "17.0.1",
"react-dom": "17.0.1",
Expand Down
6 changes: 4 additions & 2 deletions src/pages/api/ogp-images/[postid]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const generateOgpImage = async (
// setup
const canvas = createCanvas(width, height);
const ctx = canvas.getContext('2d');
registerFont(path.resolve('./fonts/NotoSansJP-Medium.otf'), {
registerFont(path.resolve(process.cwd(), 'assets', 'NotoSansJP-Medium.otf'), {
family: 'Noto Sans JP',
});
const fontFamilyName = "'Noto Sans JP'";
Expand All @@ -51,7 +51,9 @@ const generateOgpImage = async (
);

// logo
const logoImage = await loadImage(path.resolve('./public/logo.png'));
const logoImage = await loadImage(
path.resolve(process.cwd(), 'assets', 'logo.png'),
);
ctx.drawImage(
logoImage,
width - padding - margin - 380,
Expand Down
7 changes: 7 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"functions": {
"pages/api/ogp-images/[postid]/index.ts": {
"includeFiles": "assets/**"
}
}
}
212 changes: 134 additions & 78 deletions yarn.lock

Large diffs are not rendered by default.