Skip to content

Commit a2cead4

Browse files
committed
fix: remove image buffer to base 64 in qr code
1 parent e1e654e commit a2cead4

3 files changed

Lines changed: 2 additions & 12 deletions

File tree

src/generated-assets/image.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
export function imageBufferToBase64(buffer: Buffer, fileType: string) {
2-
return `data:image/${fileType};base64, ${buffer.toString("base64")}`;
3-
}
4-
51
export function getImageNameFromTsxPath(path: string) {
62
return path
73
.split("/")

src/pages/events/[id]/assets/_qrcode-bg.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
getAstroImageBase64,
44
type AssetImageConfig,
55
} from "@bearstudio/astro-assets-generation";
6-
import { imageBufferToBase64 } from "@/generated-assets/image";
76
import { BgImage } from "@/generated-assets/components/BgImage";
87
import { COLORS } from "@/generated-assets/theme";
98
import { getEventData } from "./_utils";
@@ -28,7 +27,7 @@ export default async function ({
2827
site,
2928
).toString();
3029

31-
const qrCodeBuffer = await QRCode.toBuffer(url, {
30+
const qrCodeBase64 = await QRCode.toDataURL(url, {
3231
width: 880,
3332
margin: 1,
3433
color: {
@@ -37,8 +36,6 @@ export default async function ({
3736
},
3837
});
3938

40-
const qrCodeBase64 = imageBufferToBase64(qrCodeBuffer, "png");
41-
4239
return (
4340
<Frame {...config}>
4441
<BgImage src={postCover} width={config.width} height={config.height} />

src/pages/events/[id]/assets/_qrcode.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Frame } from "@/generated-assets/components/Frame";
22
import { type AssetImageConfig } from "@bearstudio/astro-assets-generation";
3-
import { imageBufferToBase64 } from "@/generated-assets/image";
43
import { COLORS } from "@/generated-assets/theme";
54
import { getEventData } from "./_utils";
65
import { lunalink } from "@bearstudio/lunalink";
@@ -24,7 +23,7 @@ export default async function ({
2423
site,
2524
).toString();
2625

27-
const qrCodeBuffer = await QRCode.toBuffer(url, {
26+
const qrCodeBase64 = await QRCode.toDataURL(url, {
2827
width: 880,
2928
margin: 1,
3029
color: {
@@ -33,8 +32,6 @@ export default async function ({
3332
},
3433
});
3534

36-
const qrCodeBase64 = imageBufferToBase64(qrCodeBuffer, "png");
37-
3835
return (
3936
<Frame {...config}>
4037
<div

0 commit comments

Comments
 (0)