File tree 3 files changed +33
-3
lines changed
playground/components/OgImage
src/runtime/server/og-image/satori
3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ const containerStyles = {
21
21
<div :style =" containerStyles" >
22
22
<div >{{ title }}</div >
23
23
<div >{{ description }}</div >
24
- <Icon name =" carbon:book" size =" 250px" class =" text-blue-500/30" style =" margin : 0 auto ;" />
25
- <Icon name =" carbon:star" size =" 250px" class =" text-blue-500" style =" margin : 0 auto ;" />
26
- <Icon name =" uil:github" size =" 250px" class =" text-blue-500" style =" margin : 0 auto ;" />
24
+ <Icon mode = " svg " name =" carbon:book" size =" 250px" class =" size-30 text-blue-500/30" style =" margin : 0 auto ;" />
25
+ <Icon name =" carbon:star" size =" 250px" class =" size-30 text-blue-500" style =" margin : 0 auto ;" />
26
+ <Icon mode = " svg " name =" uil:github" size =" 250px" class =" size-30 text-blue-500" style =" margin : 0 auto ;" />
27
27
</div >
28
28
</template >
Original file line number Diff line number Diff line change
1
+ import type { VNode } from '../../../../types'
2
+ import { logger } from '../../../util/logger'
3
+ import { defineSatoriTransformer } from '../utils'
4
+
5
+ export default defineSatoriTransformer ( [
6
+ // need to make sure parent div has flex for the emoji to render inline
7
+ {
8
+ filter : ( node : VNode ) =>
9
+ node . type === 'span' && node . props ?. class ?. includes ( 'iconify' ) ,
10
+ transform : ( node : VNode , e ) => {
11
+ if ( import . meta. dev ) {
12
+ logger . warn ( `When using the Nuxt Icon components in \`${ e . options . component } \` you must provide \`mode="svg"\` to ensure correct rendering.` )
13
+ }
14
+ } ,
15
+ } ,
16
+ // need to make sure parent div has flex for the emoji to render inline
17
+ {
18
+ filter : ( node : VNode ) =>
19
+ node . type === 'svg' && node . props ?. class ?. includes ( 'iconify' ) ,
20
+ transform : ( node : VNode , e ) => {
21
+ // strip classes
22
+ node . props . class = node . props . class
23
+ . split ( ' ' )
24
+ . filter ( c => ! c . startsWith ( 'iconify' ) )
25
+ . join ( ' ' )
26
+ } ,
27
+ } ,
28
+ ] )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import emojis from './plugins/emojis'
7
7
import encoding from './plugins/encoding'
8
8
import flex from './plugins/flex'
9
9
import imageSrc from './plugins/imageSrc'
10
+ import nuxtIcon from './plugins/nuxt-icon'
10
11
import unocss from './plugins/unocss'
11
12
import { applyEmojis } from './transforms/emojis'
12
13
import { applyInlineCss } from './transforms/inlineCss'
@@ -38,6 +39,7 @@ export async function createVNodes(ctx: OgImageRenderEventContext): Promise<VNod
38
39
classes ,
39
40
flex ,
40
41
encoding ,
42
+ nuxtIcon ,
41
43
] )
42
44
// do async transforms
43
45
await Promise . all ( walkSatoriTree ( ctx , satoriTree , [
You can’t perform that action at this time.
0 commit comments