Skip to content

Commit

Permalink
feat: GFM alerts support custom css
Browse files Browse the repository at this point in the history
  • Loading branch information
dribble-njr committed Nov 22, 2024
1 parent 53a8cd5 commit 2c26d59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/utils/MDAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ export default function markedAlert(options: AlertOptions = {}): MarkedExtension
},
})

console.log({
...options.theme?.block[className],
...options.theme?.block[`${className}-${variantType}`],
}, `style`)

const firstLine = token.tokens?.[0] as Tokens.Paragraph
const firstLineText = firstLine.raw?.replace(typeRegexp, ``).trim()

Expand Down
12 changes: 10 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export function customizeTheme(theme: Theme, options: {
export function customCssWithTemplate(jsonString: Partial<Record<Block | Inline, PropertiesHyphen>>, color: string, theme: Theme) {
const newTheme = customizeTheme(theme, { color })

const mergeProperties = <T extends Block | Inline = Block>(target: Record<T, PropertiesHyphen>, source: Partial<Record<Block | Inline, PropertiesHyphen>>, keys: T[]) => {
const mergeProperties = <T extends Block | Inline | string = Block>(target: Record<T, PropertiesHyphen>, source: Partial<Record<Block | Inline | string, PropertiesHyphen>>, keys: T[]) => {
keys.forEach((key) => {
if (source[key]) {
target[key] = Object.assign(target[key] || {}, source[key])
}
})
}

const blockKeys: Block[] = [
const blockKeys: (Block | string)[] = [
`h1`,
`h2`,
`h3`,
Expand All @@ -55,6 +55,14 @@ export function customCssWithTemplate(jsonString: Partial<Record<Block | Inline,
`hr`,
`blockquote`,
`blockquote_p`,
`markdown-alert`,
`markdown-alert-title`,
`markdown-alert-content-wrapper`,
`markdown-alert-title-note`,
`markdown-alert-title-tip`,
`markdown-alert-title-important`,
`markdown-alert-title-warning`,
`markdown-alert-title-caution`,
`image`,
`ul`,
`ol`,
Expand Down

0 comments on commit 2c26d59

Please sign in to comment.