mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 08:52:21 +00:00
fix: use publisher social image font weight
This commit is contained in:
@@ -125,4 +125,23 @@ describe("ogAssets", () => {
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("loads publisher fonts with Bricolage 700 first", async () => {
|
||||
readFileMock.mockResolvedValue(Buffer.from([9, 8, 7]));
|
||||
|
||||
const { getPublisherFontBuffers } = await import("./ogAssets");
|
||||
|
||||
const first = await getPublisherFontBuffers();
|
||||
const second = await getPublisherFontBuffers();
|
||||
|
||||
expect(first).toHaveLength(6);
|
||||
expect(second).toEqual(first);
|
||||
expect(readFileMock).toHaveBeenCalledTimes(6);
|
||||
expect(String(readFileMock.mock.calls[0]?.[0])).toContain(
|
||||
"bricolage-grotesque-latin-700-normal.woff2",
|
||||
);
|
||||
expect(String(readFileMock.mock.calls[1]?.[0])).toContain(
|
||||
"bricolage-grotesque-latin-800-normal.woff2",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ let clawHubLogoDataUrlPromise: Promise<string> | null = null;
|
||||
let watermarkDataUrlPromise: Promise<string> | null = null;
|
||||
let resvgWasmPromise: Promise<Uint8Array> | null = null;
|
||||
let fontBuffersPromise: Promise<Uint8Array[]> | null = null;
|
||||
let publisherFontBuffersPromise: Promise<Uint8Array[]> | null = null;
|
||||
let resvgInitPromise: Promise<void> | null = null;
|
||||
|
||||
function getServerRootUrl() {
|
||||
@@ -130,3 +131,41 @@ export async function getFontBuffers() {
|
||||
}
|
||||
return fontBuffersPromise;
|
||||
}
|
||||
|
||||
export async function getPublisherFontBuffers() {
|
||||
if (!publisherFontBuffersPromise) {
|
||||
publisherFontBuffersPromise = Promise.all([
|
||||
readFile(
|
||||
getServerUrl(
|
||||
"node_modules/@fontsource/bricolage-grotesque/files/bricolage-grotesque-latin-700-normal.woff2",
|
||||
),
|
||||
),
|
||||
readFile(
|
||||
getServerUrl(
|
||||
"node_modules/@fontsource/bricolage-grotesque/files/bricolage-grotesque-latin-800-normal.woff2",
|
||||
),
|
||||
),
|
||||
readFile(
|
||||
getServerUrl(
|
||||
"node_modules/@fontsource/bricolage-grotesque/files/bricolage-grotesque-latin-500-normal.woff2",
|
||||
),
|
||||
),
|
||||
readFile(
|
||||
getServerUrl(
|
||||
"node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-500-normal.woff2",
|
||||
),
|
||||
),
|
||||
readFile(
|
||||
getServerUrl(
|
||||
"node_modules/@fontsource/noto-sans-sc/files/noto-sans-sc-chinese-simplified-800-normal.woff2",
|
||||
),
|
||||
),
|
||||
readFile(
|
||||
getServerUrl(
|
||||
"node_modules/@fontsource/noto-sans-sc/files/noto-sans-sc-chinese-simplified-500-normal.woff2",
|
||||
),
|
||||
),
|
||||
]).then((buffers) => buffers.map((buffer) => new Uint8Array(buffer)));
|
||||
}
|
||||
return publisherFontBuffersPromise;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
FONT_MONO,
|
||||
FONT_SANS,
|
||||
getClawHubLogoDataUrl,
|
||||
getFontBuffers,
|
||||
getPublisherFontBuffers,
|
||||
} from "../../og/ogAssets";
|
||||
import { pngResponse } from "../../og/pngResponse";
|
||||
import { buildPublisherOgSvg } from "../../og/publisherOgSvg";
|
||||
@@ -78,7 +78,7 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const [clawHubLogoDataUrl, fontBuffers] = await Promise.all([
|
||||
getClawHubLogoDataUrl(),
|
||||
ensureResvgWasm().then(() => getFontBuffers()),
|
||||
ensureResvgWasm().then(() => getPublisherFontBuffers()),
|
||||
]);
|
||||
const avatarDataUrl = await fetchPublisherProfileImageDataUrl(avatarFromQuery || meta?.image);
|
||||
const organizationImageUrls =
|
||||
|
||||
Reference in New Issue
Block a user