This example demonstrates how to use the Vitepress buildEnd hook to generate Open Graph image.
npx degit Zhengqbbb/x-satori/examples/vue-vitepress <file_name>
cd <file_name>
npm install
# Development Image Template Model
npm run dev:og
# Development Website
npm run dev
# Build Website
npm run build
# Preview Website
npm run preview
npm install -D x-satori @resvg/resvg-js
- x-satori - Using Vue file (.vue) as template to generate image SVG.
- @resvg/resvg-js - Convert SVG to PNG.
.
├── config.ts # x-satori Configuration file - Provide for index.ts and x-satori dev CLI
├── index.ts # Provide for .vitepress/config.ts
└── Template.vue # Vue file template - Provide for index.ts and x-satori dev CLI
Tip
Can using x-satori
CLI to create dev server to preview and design the vue template
npm run dev:og
import { defineConfig } from 'vitepress'
import { generateOGImage } from './og'
// https://vitepress.dev/reference/site-config
export default defineConfig({
// ...
buildEnd: async (config) => {
await generateOGImage(config)
},
// ...
})
Check it .vitepress/dist/og