Skip to content

Commit 3132c31

Browse files
committed
feat: add style support for markdown component
1 parent d3443c3 commit 3132c31

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

astro-components/src/components/Markdown.astro

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,33 @@ import { parseMarkdown, ParserOptions } from '../utils/markdown'
55
66
export type Props = {
77
['class']?: string
8-
['class:list']?: AstroBuiltinAttributes
8+
['class:list']?: AstroBuiltinAttributes['class:list']
9+
style?: any
10+
911
as?: string
1012
content: string
1113
options?: ParserOptions
1214
}
1315
1416
const {
15-
['class']: className,
16-
['class:list']: classList,
17+
['class']: className = '',
18+
['class:list']: classList = {},
19+
style = {},
20+
1721
as: Tag,
1822
content,
1923
options,
2024
} = Astro.props
2125
2226
const html = await parseMarkdown(content, options)
27+
28+
if (import.meta.env.DEV && !Tag && (className || classList || style)) {
29+
console.warn('[astro-components] using Markdown component without `as` will ignore `className`, `classList` nor `style` attributes.')
30+
}
2331
---
2432

2533
{
2634
Tag
27-
? <Tag class:list={[className, classList]} set:html={html} />
35+
? <Tag class:list={[className, classList]} style={style} set:html={html} />
2836
: <Fragment set:html={html} />
2937
}

0 commit comments

Comments
 (0)