@@ -9,6 +9,7 @@ import { cache } from "./cache.js";
9
9
10
10
interface Props extends HTMLAttributes <" svg" > {
11
11
name: Icon ;
12
+ " is:inline" ? : boolean ;
12
13
title? : string ;
13
14
size? : number ;
14
15
width? : number ;
@@ -24,7 +25,7 @@ class AstroIconError extends Error {
24
25
}
25
26
26
27
const req = Astro .request ;
27
- const { name = " " , title, ... props } = Astro .props ;
28
+ const { name = " " , title, " is:inline " : inline = false , ... props } = Astro .props ;
28
29
const map = cache .get (req ) ?? new Map ();
29
30
const i = map .get (name ) ?? 0 ;
30
31
map .set (name , i + 1 );
@@ -33,7 +34,7 @@ cache.set(req, map);
33
34
const { include = {} } = config ;
34
35
const sets = Object .keys (include );
35
36
36
- const includeSymbol = i === 0 ;
37
+ const includeSymbol = ! inline && i === 0 ;
37
38
38
39
let [setName, iconName] = (name as string ).split (" :" );
39
40
@@ -115,6 +116,14 @@ const normalizedBody = renderData.body;
115
116
116
117
<svg {... normalizedProps } data-icon ={ name } >
117
118
{ title && <title >{ title } </title >}
118
- { includeSymbol && <symbol id = { id } set :html = { normalizedBody } />}
119
- <use xlink:href ={ ` #${id } ` } ></use >
119
+ {
120
+ inline ? (
121
+ <Fragment id = { id } set :html = { normalizedBody } />
122
+ ) : (
123
+ <Fragment >
124
+ { includeSymbol && <symbol id = { id } set :html = { normalizedBody } />}
125
+ <use xlink :href = { ` #${id } ` } />
126
+ </Fragment >
127
+ )
128
+ }
120
129
</svg >
0 commit comments