chore: change syntax from :::type{title} to :::type[title]

This commit is contained in:
radishzzz 2025-04-30 17:00:30 +01:00
parent 23ba4de450
commit f59b4c691a
4 changed files with 516 additions and 501 deletions

View file

@ -2,7 +2,7 @@
"name": "astro-theme-retypeset",
"type": "module",
"version": "0.0.1",
"packageManager": "pnpm@10.9.0",
"packageManager": "pnpm@10.10.0",
"repository": "https://github.com/radishzzz/astro-theme-retypeset",
"scripts": {
"dev": "astro check && astro dev",
@ -13,12 +13,12 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@astrojs/mdx": "^4.2.5",
"@astrojs/mdx": "^4.2.6",
"@astrojs/partytown": "^2.1.4",
"@astrojs/rss": "^4.0.11",
"@astrojs/sitemap": "^3.3.1",
"@waline/client": "^3.5.6",
"astro": "^5.7.5",
"astro": "^5.7.10",
"astro-compress": "^2.3.8",
"astro-og-canvas": "^0.7.0",
"astro-robots-txt": "^1.0.0",
@ -42,18 +42,18 @@
"@antfu/eslint-config": "^4.12.0",
"@astrojs/check": "^0.9.4",
"@types/markdown-it": "^14.1.2",
"@types/node": "^22.15.2",
"@types/node": "^22.15.3",
"@types/sanitize-html": "^2.15.0",
"@unocss/eslint-plugin": "66.1.0-beta.12",
"@unocss/preset-attributify": "66.1.0-beta.12",
"@unocss/reset": "66.1.0-beta.12",
"@unocss/eslint-plugin": "66.1.0-beta.13",
"@unocss/preset-attributify": "66.1.0-beta.13",
"@unocss/reset": "66.1.0-beta.13",
"astro-eslint-parser": "^1.2.2",
"eslint": "^9.25.1",
"eslint-plugin-astro": "^1.3.1",
"lint-staged": "^15.5.1",
"sharp": "^0.34.1",
"typescript": "~5.8.3",
"unocss": "66.1.0-beta.12",
"unocss": "66.1.0-beta.13",
"unocss-preset-theme": "^0.14.1"
},
"lint-staged": {

978
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -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.
![_图片描述](./full/or/relative/path/of/image)
![](./full/or/relative/path/of/image)
```
```

View file

@ -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)
})