mirror of
https://github.com/fmhy/edit.git
synced 2026-02-18 09:11:33 +11:00
improve
This commit is contained in:
parent
e886f8dfbf
commit
c7f6b4a0be
1 changed files with 17 additions and 27 deletions
|
|
@ -7,32 +7,23 @@ import { defineSatoriConfig } from 'x-satori/vue'
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||||
const __fonts = resolve(__dirname, '../fonts')
|
const __fonts = resolve(__dirname, '../fonts')
|
||||||
|
|
||||||
const fonts: SatoriOptions['fonts'] = [
|
const loadFont = async (fontName: string, weight: number, style: string) => {
|
||||||
{
|
try {
|
||||||
name: 'Inter',
|
const fontFile = resolve(__fonts, `${fontName}-${weight}.otf`)
|
||||||
data: await readFile(resolve(__fonts, 'Inter-Regular.otf')),
|
const fontData = await readFile(fontFile)
|
||||||
weight: 400,
|
return { name: fontName, data: fontData, weight, style }
|
||||||
style: 'normal'
|
} catch (error) {
|
||||||
},
|
console.error(`Error loading font ${fontName} with weight ${weight}:`, error)
|
||||||
{
|
return null
|
||||||
name: 'Inter',
|
|
||||||
data: await readFile(resolve(__fonts, 'Inter-Medium.otf')),
|
|
||||||
weight: 500,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Inter',
|
|
||||||
data: await readFile(resolve(__fonts, 'Inter-SemiBold.otf')),
|
|
||||||
weight: 600,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Inter',
|
|
||||||
data: await readFile(resolve(__fonts, 'Inter-Bold.otf')),
|
|
||||||
weight: 700,
|
|
||||||
style: 'normal'
|
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
|
|
||||||
|
const fonts: SatoriOptions['fonts'] = [
|
||||||
|
await loadFont('Inter', 400, 'normal'),
|
||||||
|
await loadFont('Inter', 500, 'normal'),
|
||||||
|
await loadFont('Inter', 600, 'normal'),
|
||||||
|
await loadFont('Inter', 700, 'normal'),
|
||||||
|
].filter(font => font !== null)
|
||||||
|
|
||||||
export default defineSatoriConfig({
|
export default defineSatoriConfig({
|
||||||
width: 1200,
|
width: 1200,
|
||||||
|
|
@ -40,8 +31,7 @@ export default defineSatoriConfig({
|
||||||
fonts,
|
fonts,
|
||||||
props: {
|
props: {
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
description:
|
description: `Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.`,
|
||||||
'Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.',
|
|
||||||
dir: '/j'
|
dir: '/j'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue