mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 03:32:51 +02:00
chore: change syntax from :::type{title} to :::type[title]
This commit is contained in:
parent
23ba4de450
commit
f59b4c691a
4 changed files with 516 additions and 501 deletions
|
@ -3,6 +3,7 @@ title: Markdown 扩展功能
|
|||
published: 2025-04-25
|
||||
tags:
|
||||
- 指南
|
||||
draft: true
|
||||
toc: false
|
||||
lang: zh
|
||||
abbrlink: markdown-extended-features
|
||||
|
@ -24,7 +25,7 @@ Useful information that users should know, even when skimming content.
|
|||
> [!NOTE]
|
||||
> Useful information that users should know, even when skimming content.
|
||||
|
||||
:::note{title="YOUR CUSTOM TITLE"}
|
||||
:::note[YOUR CUSTOM TITLE]
|
||||
This is a note with a custom title.
|
||||
:::
|
||||
```
|
||||
|
@ -48,7 +49,7 @@ Urgent info that needs immediate user attention to avoid problems.
|
|||
Advises about risks or negative outcomes of certain actions.
|
||||
:::
|
||||
|
||||
:::note{title="YOUR CUSTOM TITLE"}
|
||||
:::note[YOUR CUSTOM TITLE]
|
||||
This is a note with a custom title.
|
||||
:::
|
||||
|
||||
|
@ -70,4 +71,4 @@ This is a note with a custom title.
|
|||

|
||||
|
||||

|
||||
```
|
||||
```
|
||||
|
|
|
@ -37,7 +37,21 @@ export function remarkAdmonitions() {
|
|||
if (!ADMONITION_TYPES[type])
|
||||
return
|
||||
|
||||
const title = node.attributes?.title || ADMONITION_TYPES[type]
|
||||
let title = ADMONITION_TYPES[type]
|
||||
const firstChild = node.children?.[0]
|
||||
|
||||
// Use [title] syntax for custom title
|
||||
if (firstChild?.data?.directiveLabel) {
|
||||
if (firstChild.children?.length) {
|
||||
title = firstChild.children
|
||||
.map(child => child.type === 'text' ? child.value : '')
|
||||
.join('')
|
||||
.trim() || title
|
||||
}
|
||||
|
||||
node.children.shift()
|
||||
}
|
||||
|
||||
createAdmonition(node, type, title)
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue