From bc005736f67830d0501890443ed44e8c5b5ec6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=98?= Date: Fri, 10 Jan 2025 23:27:23 +0800 Subject: [PATCH] :art: --- src/components/markdown/img.astro | 2 +- src/pages/menu/typography/image.mdx | 2 +- src/pages/menu/typography/paragraph.mdx | 2 +- src/scripts/server/dataset.ts | 8 ++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/markdown/img.astro b/src/components/markdown/img.astro index 46a475a3..efdaf4b9 100644 --- a/src/components/markdown/img.astro +++ b/src/components/markdown/img.astro @@ -13,7 +13,7 @@ const props = Astro.props ondragstart="return false" onerror={` this.src='${unknow.src}'; - this.parentElement.dataset.error=true; + this.parentElement.dataset.error=''; this.onerror='return false' `} /> diff --git a/src/pages/menu/typography/image.mdx b/src/pages/menu/typography/image.mdx index 3225a4b8..ed71d9d3 100644 --- a/src/pages/menu/typography/image.mdx +++ b/src/pages/menu/typography/image.mdx @@ -174,7 +174,7 @@ style(lang='stylus'). .☘-image-footer-content .☘-title(data-size=5) | 标题标题标题标题标题标题标题标题标题标题标题 - .☘-paragraph(data-ellipsis="1") + .☘-paragraph(data-ellipsis=1) | 描述描述描述描述描述描述描述描述描述描述描述描述 .☘-image-footer-action svg.☘-link( diff --git a/src/pages/menu/typography/paragraph.mdx b/src/pages/menu/typography/paragraph.mdx index bf26ecec..95f95a2f 100644 --- a/src/pages/menu/typography/paragraph.mdx +++ b/src/pages/menu/typography/paragraph.mdx @@ -60,7 +60,7 @@ markdown中的空格另起一行即为 `

` ```pug div(style={width: "20em"}) - .☘-paragraph(data-has-indent data-ellipsis="5") + .☘-paragraph(data-has-indent data-ellipsis=5) | 我欲因之梦吴越,一夜飞度镜湖月。 湖月照我影,送我至剡溪。 | 谢公宿处今尚在,渌水荡漾清猿啼。 脚著谢公屐,身登青云梯。 | 半壁见海日,空中闻天鸡。 千岩万转路不定,迷花倚石忽已暝。 diff --git a/src/scripts/server/dataset.ts b/src/scripts/server/dataset.ts index e23b99ee..fc81b8f7 100644 --- a/src/scripts/server/dataset.ts +++ b/src/scripts/server/dataset.ts @@ -1,7 +1,11 @@ export default function (dataset: Record) { - const attrs: Record<`data-${string}`, string> = {} + const attrs: Record<`data-${string}`, string | null> = {} for (const [k, v] of Object.entries(dataset)) { - Reflect.set(attrs, `data-${k}`, `${v}`) + let unbv: string | null + if (v === true) unbv = "" + else if (v === false) unbv = null + else unbv = `${v ?? ""}` + Reflect.set(attrs, `data-${k}`, unbv) } return attrs }