Skip to content

Commit

Permalink
fix return
Browse files Browse the repository at this point in the history
  • Loading branch information
vasfvitor committed Oct 11, 2023
1 parent d140c66 commit 4acf17e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/pages/social-images/[...path].png.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// 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/

// TODO: Define default or import from somewhere else
const SITE_TITLE = 'Tauri';
const SITE_DESCRIPTION = 'Tauri is awesome';
Expand Down Expand Up @@ -32,7 +34,7 @@ export async function getStaticPaths() {
return paths.map((path) => ({ params: { path } }));
}

export async function get({ params, request }) {
export async function GET({ params, request }) {
const getInfo = blogPosts[params.path];

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

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

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

0 comments on commit 4acf17e

Please sign in to comment.