Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wobsoriano/v-satori

Generate a satori-friendly VDOM from a Vue component
https://github.com/wobsoriano/v-satori

nuxt satori vue

Last synced: about 1 month ago
JSON representation

Generate a satori-friendly VDOM from a Vue component

Awesome Lists containing this project

README

        

# v-satori

Generate a [satori](https://github.com/vercel/satori)-friendly VDOM from a Vue component. Uses [satori-html](https://github.com/natemoo-re/satori-html).

## Installion

```bash
npm install satori v-satori
```

## Usage

Nuxt 3

```ts
export default defineNuxtConfig({
modules: ['v-satori/nuxt']
})
```

```vue

defineProps({
title: String,
website: String,
})





{{ title }}



{{ website }}



```

```ts
// server/api/og.ts

import { satori } from 'v-satori'
import Image from '@/components/Image.vue'
// https://github.com/wobsoriano/unplugin-font-to-buffer
import Roboto from '@/lib/fonts/Roboto-Regular.ttf'

export default eventHandler(async (event) => {
const query = getQuery(event)

const svg = await satori(Image, {
props: {
title: query.title,
website: query.website
},
width: 1200,
height: 630,
fonts: [{
name: 'Roboto',
data: Roboto,
weight: 400,
style: 'normal',
}]
})

setHeader(event, 'Content-Type', 'image/svg+xml')

return svg
})
```

You can then create new dynamic images by passing the following parameters to the API endpoint:

```vue

const title = 'OG Image Generator using Nuxt and Satori'
const website = 'v3.nuxtjs.org'



```

Output:

## License

MIT