mirror of
https://github.com/wavetermdev/docusaurus-og.git
synced 2026-08-05 13:46:35 -07:00
Don't dynamically import resvg
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ const fs = tslib_1.__importStar(require("fs"));
|
||||
const fsp = tslib_1.__importStar(require("fs/promises"));
|
||||
const object_hash_1 = tslib_1.__importDefault(require("object-hash"));
|
||||
const path_1 = tslib_1.__importDefault(require("path"));
|
||||
const resvg_js_1 = require("@resvg/resvg-js");
|
||||
class ImageGenerator {
|
||||
args;
|
||||
satori;
|
||||
@@ -28,8 +29,7 @@ class ImageGenerator {
|
||||
const absolutePath = path_1.default.join(this.outDir, imageName);
|
||||
const relativePath = path_1.default.join('/', this.args.dir, absolutePath.slice(this.outDir.length));
|
||||
const svg = await this.satori(element, options);
|
||||
const { Resvg } = await import('@resvg/resvg-js').then(module => module);
|
||||
const pngBuffer = new Resvg(svg).render().asPng();
|
||||
const pngBuffer = new resvg_js_1.Resvg(svg).render().asPng();
|
||||
await fsp.writeFile(absolutePath, pngBuffer);
|
||||
const url = new URL(this.args.websiteUrl);
|
||||
url.pathname = relativePath;
|
||||
|
||||
@@ -6,6 +6,7 @@ import React from 'react'
|
||||
|
||||
import type Satori from 'satori'
|
||||
import { type SatoriOptions } from 'satori'
|
||||
import { Resvg } from '@resvg/resvg-js'
|
||||
|
||||
|
||||
export type ImageGeneratorOptions = SatoriOptions
|
||||
@@ -55,7 +56,6 @@ export class ImageGenerator {
|
||||
)
|
||||
|
||||
const svg = await this.satori(element, options)
|
||||
const { Resvg } = await import('@resvg/resvg-js').then(module => module)
|
||||
|
||||
const pngBuffer = new Resvg(svg).render().asPng()
|
||||
await fsp.writeFile(absolutePath, pngBuffer)
|
||||
|
||||
Reference in New Issue
Block a user