From 3132c31a137eec32f224a39882af20d36a3e04c1 Mon Sep 17 00:00:00 2001 From: Julien Barbay Date: Mon, 18 Dec 2023 18:12:11 +0700 Subject: [PATCH] feat: add style support for markdown component --- astro-components/src/components/Markdown.astro | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/astro-components/src/components/Markdown.astro b/astro-components/src/components/Markdown.astro index 3b7bdb6..d22260b 100644 --- a/astro-components/src/components/Markdown.astro +++ b/astro-components/src/components/Markdown.astro @@ -5,25 +5,33 @@ import { parseMarkdown, ParserOptions } from '../utils/markdown' export type Props = { ['class']?: string - ['class:list']?: AstroBuiltinAttributes + ['class:list']?: AstroBuiltinAttributes['class:list'] + style?: any + as?: string content: string options?: ParserOptions } const { - ['class']: className, - ['class:list']: classList, + ['class']: className = '', + ['class:list']: classList = {}, + style = {}, + as: Tag, content, options, } = Astro.props const html = await parseMarkdown(content, options) + +if (import.meta.env.DEV && !Tag && (className || classList || style)) { + console.warn('[astro-components] using Markdown component without `as` will ignore `className`, `classList` nor `style` attributes.') +} --- { Tag - ? + ? : }