diff --git a/assets/css/_core/_root.scss b/assets/css/_core/_root.scss index dd4af56d2..20357ffa3 100644 --- a/assets/css/_core/_root.scss +++ b/assets/css/_core/_root.scss @@ -1,7 +1,7 @@ :root { // Note: Custom variable values only support SassScript inside `#{}`. - // Theme colors varibles + // Theme colors variables @each $color, $value in $theme-colors { --#{$prefix}#{$color}: #{$value}; } @@ -22,6 +22,8 @@ --#{$prefix}scrollbar-track-color: transparent; --#{$prefix}scrollbar-width: thin; --#{$prefix}scrollbar-width-legacy: 12px; + + // TODO migrate SCSS variables to CSS variables } // Dark theme diff --git a/assets/css/_page/_single.scss b/assets/css/_page/_single.scss index 8785de12e..c9c02e29f 100644 --- a/assets/css/_page/_single.scss +++ b/assets/css/_page/_single.scss @@ -230,6 +230,38 @@ ul { list-style-type: disc; + + // Task lists + li[data-task] { + list-style: none; + margin-left: -1.5rem; + } + } + + // Task lists + li[data-task] { + color: var(--#{$prefix}task-color); + .checkbox-icon { + margin-right: 0.25em; + color: var(--#{$prefix}checkbox-color); + } + } + li[data-task='x'], + li[data-task='-'] { + --#{$prefix}task-color: var(--#{$prefix}secondary); + text-decoration: line-through; + } + li[data-task='x'] { + --#{$prefix}checkbox-color: var(--#{$prefix}primary); + } + li[data-task='/'] { + --#{$prefix}task-color: var(--#{$prefix}success); + } + li[data-task='!'] { + --#{$prefix}checkbox-color: var(--#{$prefix}danger); + } + li[data-task='?'] { + --#{$prefix}checkbox-color: var(--#{$prefix}warning); } dl { diff --git a/hugo.toml b/hugo.toml index 1d268ea06..474d4595a 100644 --- a/hugo.toml +++ b/hugo.toml @@ -688,6 +688,12 @@ enableEmoji = true # syntax: = [params.admonition] # ban = "fa-solid fa-ban" + + # FixIt 0.3.14 | NEW Task lists custom config + # See https://fixit.lruihao.cn/documentation/content-management/advanced/#custom-task-lists + # syntax: = + [params.taskList] + # tip = "fa-regular fa-lightbulb" # FixIt 0.2.12 | NEW PanguJS config [params.pangu] diff --git a/i18n/de.toml b/i18n/de.toml index fb2fa6f34..e5a586d04 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Notiz" diff --git a/i18n/en.toml b/i18n/en.toml index e3ae77b3b..8af9099d3 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -181,6 +181,18 @@ warning = "Warning" caution = "Caution" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "Unchecked" +"x" = "Checked" +"/" = "In Progress" +"-" = "Cancelled" +"<" = "Scheduled" +">" = "Rescheduled" +"!" = "Important" +"?" = "Question" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Note" diff --git a/i18n/es.toml b/i18n/es.toml index 55ba8a003..25cd8fa9d 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Nota" diff --git a/i18n/fr.toml b/i18n/fr.toml index 4a07ca56d..a2a3b1154 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -181,6 +181,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Remarque" diff --git a/i18n/hi.toml b/i18n/hi.toml index 75b46b2a9..1ef3a376c 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "ध्यान दें" diff --git a/i18n/it.toml b/i18n/it.toml index 8c72e96f4..048a063b4 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Note" diff --git a/i18n/pl.toml b/i18n/pl.toml index be142e67f..65d167073 100644 --- a/i18n/pl.toml +++ b/i18n/pl.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Notka" diff --git a/i18n/pt-BR.toml b/i18n/pt-BR.toml index ceccd54dc..00ac15c86 100644 --- a/i18n/pt-BR.toml +++ b/i18n/pt-BR.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Nota" diff --git a/i18n/ro.toml b/i18n/ro.toml index 85a24a479..1b572ceec 100644 --- a/i18n/ro.toml +++ b/i18n/ro.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Notă" diff --git a/i18n/ru.toml b/i18n/ru.toml index b5fd91e12..cdf5699e9 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Замечание" diff --git a/i18n/sr.toml b/i18n/sr.toml index ae3a6dea1..820953905 100644 --- a/i18n/sr.toml +++ b/i18n/sr.toml @@ -182,6 +182,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Напомена" diff --git a/i18n/vi.toml b/i18n/vi.toml index ada6b9ffd..c29f2265c 100644 --- a/i18n/vi.toml +++ b/i18n/vi.toml @@ -181,6 +181,18 @@ warning = "" caution = "" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "" +"x" = "" +"/" = "" +"-" = "" +"<" = "" +">" = "" +"!" = "" +"?" = "" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "Ghi chú" diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml index 7f13f6c8e..03524599f 100644 --- a/i18n/zh-CN.toml +++ b/i18n/zh-CN.toml @@ -177,6 +177,18 @@ warning = "警告" caution = "小心" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "未完成" +"x" = "已完成" +"/" = "进行中" +"-" = "已取消" +"<" = "已计划" +">" = "已重新计划" +"!" = "重要" +"?" = "问题" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "注意" diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml index 53092dead..6ee437bc1 100644 --- a/i18n/zh-TW.toml +++ b/i18n/zh-TW.toml @@ -177,6 +177,18 @@ warning = "警告" caution = "小心" # === GitHub Alert === +# === Task lists === +[taskList] +" " = "未完成" +"x" = "已完成" +"/" = "進行中" +"-" = "已取消" +"<" = "已計劃" +">" = "已重新計劃" +"!" = "重要" +"?" = "問題" +# === Task lists === + # === shortcodes/admonition.html === [admonition] note = "注意" diff --git a/layouts/partials/function/checkbox.html b/layouts/partials/function/checkbox.html deleted file mode 100644 index 1b636bb4a..000000000 --- a/layouts/partials/function/checkbox.html +++ /dev/null @@ -1,9 +0,0 @@ -{{- /* Checkbox unchecked */ -}} -{{- $old := `` -}} -{{- $new := dict "Class" "fa-regular fa-square fa-fw" | partial "plugin/icon.html" -}} -{{- $content := replace . $old $new -}} - -{{- /* Checkbox checked */ -}} -{{- $old = `` -}} -{{- $new := dict "Class" "fa-regular fa-check-square fa-fw" | partial "plugin/icon.html" -}} -{{- return replace $content $old $new -}} diff --git a/layouts/partials/function/content.html b/layouts/partials/function/content.html index b232c4320..426b653c3 100644 --- a/layouts/partials/function/content.html +++ b/layouts/partials/function/content.html @@ -14,7 +14,7 @@ {{- $content = partial "function/fontawesome.html" $content -}} {{- end -}} - {{- $content = partial "function/checkbox.html" $content -}} + {{- $content = partial "function/task-lists.html" $content -}} {{- $content = partial "function/escape.html" $content -}} diff --git a/layouts/partials/function/task-lists.html b/layouts/partials/function/task-lists.html new file mode 100644 index 000000000..b382da87c --- /dev/null +++ b/layouts/partials/function/task-lists.html @@ -0,0 +1,55 @@ +{{- /* Task lists rendering */ -}} +{{- /* If Hugo supports the list rendering hook, refactor this snippet. */ -}} + +{{- $iconMap := dict + " " "fa-regular fa-square" + "x" "fa-solid fa-check-square" + "/" "fa-regular fa-square" + "-" "fa-solid fa-square-xmark" + "<" "fa-regular fa-calendar-plus" + ">" "fa-regular fa-calendar-minus" + "!" "fa-solid fa-circle-exclamation" + "\\?" "fa-regular fa-circle-question" +-}} +{{- /* Custom Task lists */ -}} +{{- $iconMap = site.Params.taskList | merge $iconMap -}} + +{{- /* Get the extended signs */ -}} +{{- $extendedSigns := slice -}} +{{- range $sign, $icon := $iconMap -}} + {{- $extendedSigns = $extendedSigns | append $sign -}} +{{- end -}} + +{{- /* + The basic syntax is compatible with GitHub, Obsidian, and Typora. + The basic format is as follows: + - [ ] Unchecked + - [x] Checked +*/ -}} +{{- $icon := dict "Class" (add "checkbox-icon fa-fw " (index $iconMap " ")) | partial "plugin/icon.html" -}} +{{- $label := T (printf "taskList.%v" " ") -}} +{{- $content := replaceRE `
  • (.+?)
  • ` (printf `
  • %s$1
  • ` $label $icon) . -}} +{{- $label := T (printf "taskList.%v" "x") -}} +{{- $icon := dict "Class" (add "checkbox-icon fa-fw " (index $iconMap "x")) | partial "plugin/icon.html" -}} +{{- $content = replaceRE `
  • (.+?)
  • ` (printf `
  • %s$1
  • ` $label $icon) $content -}} + +{{- /* + The extended syntax is compatible with Obsidian. + The extended format is as follows: + - [-] Cancelled + - [/] In Progress + - [<] Scheduled + - [>] Rescheduled + - [!] Important + - [?] Question +*/ -}} +{{- range $extendedSigns -}} + {{- $class := index $iconMap . | default "fa-solid fa-check-square" -}} + {{- $icon := dict "Class" (add "checkbox-icon fa-fw " $class) | partial "plugin/icon.html" -}} + {{- $sign := htmlEscape . -}} + {{- $originSign := replace . "\\" "" -}} + {{- $label := (T (printf "taskList.%v" $originSign)) | default (T (printf "taskList.%v" " ")) -}} + {{- $content = replaceRE (printf `
  • \[%s\] (.+?)
  • ` $sign) (printf `
  • %s$1
  • ` $originSign $label $icon) $content -}} +{{- end -}} + +{{- return $content -}}