mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:01:42 +08:00
fix: add font-weight param in og image card style (#453)
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
async function loadGoogleFont(
|
async function loadGoogleFont(
|
||||||
font: string,
|
font: string,
|
||||||
text: string
|
text: string,
|
||||||
|
weight: number
|
||||||
): Promise<ArrayBuffer> {
|
): Promise<ArrayBuffer> {
|
||||||
const API = `https://fonts.googleapis.com/css2?family=${font}&text=${encodeURIComponent(text)}`;
|
const API = `https://fonts.googleapis.com/css2?family=${font}:wght@${weight}&text=${encodeURIComponent(text)}`;
|
||||||
|
|
||||||
const css = await (
|
const css = await (
|
||||||
await fetch(API, {
|
await fetch(API, {
|
||||||
@@ -51,7 +52,7 @@ async function loadGoogleFonts(
|
|||||||
|
|
||||||
const fonts = await Promise.all(
|
const fonts = await Promise.all(
|
||||||
fontsConfig.map(async ({ name, font, weight, style }) => {
|
fontsConfig.map(async ({ name, font, weight, style }) => {
|
||||||
const data = await loadGoogleFont(font, text);
|
const data = await loadGoogleFont(font, text, weight);
|
||||||
return { name, data, weight, style };
|
return { name, data, weight, style };
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user