Skip to content

Commit 4acf17e

Browse files
committed
fix return
reference: https://docs.astro.build/en/core-concepts/endpoints/#static-file-endpoints added note to a current issue
1 parent d140c66 commit 4acf17e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/pages/social-images/[...path].png.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ISSUE: Some pages don't have description field in the frontmatter, but have title. In those cases it is returning undefined written on the OG image. Example: /features/commands/
2+
13
// TODO: Define default or import from somewhere else
24
const SITE_TITLE = 'Tauri';
35
const SITE_DESCRIPTION = 'Tauri is awesome';
@@ -32,7 +34,7 @@ export async function getStaticPaths() {
3234
return paths.map((path) => ({ params: { path } }));
3335
}
3436

35-
export async function get({ params, request }) {
37+
export async function GET({ params, request }) {
3638
const getInfo = blogPosts[params.path];
3739

3840
let template;
@@ -47,11 +49,7 @@ export async function get({ params, request }) {
4749
const svgBuffer = Buffer.from(template);
4850
const body = await sharp(svgBuffer).resize(1200, 675).png().toBuffer();
4951

50-
// TODO: Check return type and function definition on https://docs.astro.build/en/core-concepts/endpoints/#static-file-endpoints
51-
return {
52-
body,
53-
encoding: 'binary',
54-
};
52+
return new Response(body);
5553
}
5654

5755
// breaks a string into a set of strings with a maximum length.
@@ -88,7 +86,7 @@ function createTemplate(title: string, description: string): string {
8886
3,
8987
40
9088
);
91-
// TODO: Make a proper design and revise text layout
89+
// TODO: Make a proper design and revise text layout.
9290
return `
9391
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 1200 675">
9492
<style>

0 commit comments

Comments
 (0)