Добавить поддержку callouts из Obsidian и стили для них; обновить конфигурацию SASS

This commit is contained in:
ada
2025-08-22 13:31:11 +03:00
parent 439ea4affb
commit 3a87f2a568
3 changed files with 84 additions and 0 deletions
+3
View File
@@ -8,6 +8,9 @@ favicon: /assets/images/favicons/favicon.ico
locale: ru
sass:
style: compressed
analytics:
provider: "google-gtag" # встроенная интеграция
google:
+54
View File
@@ -0,0 +1,54 @@
# _plugins/obsidian_callouts.rb
# Конвертирует Obsidian callouts ( > [!type] title ... )
# в HTML блоки .callout.<type>
module Jekyll
class ObsidianCallouts
CALLOUTS = {
"note" => {label: "Заметка", css: "note"},
"info" => {label: "Инфо", css: "info"},
"tip" => {label: "Подсказка",css: "tip"},
"success" => {label: "Готово", css: "success"},
"warning" => {label: "Внимание", css: "warning"},
"bug" => {label: "Баг", css: "bug"},
"danger" => {label: "Опасно", css: "danger"},
"error" => {label: "Ошибка", css: "danger"},
"quote" => {label: "Цитата", css: "quote"}
}.freeze
# > [!TYPE] Optional title
# > line
# > line
REGEX = /
^>\s*\[!(?<type>[A-Za-z_-]+)\]\s*(?<title>[^\n]*)\n # шапка callout
(?<body>(?:^>.*\n)+) # все следующие строки, начинающиеся с >
/x
# запустим перед рендером markdown → html
Jekyll::Hooks.register [:pages, :documents], :pre_render do |doc|
next unless doc.content
content = doc.content.dup
content.gsub!(REGEX) do
m = Regexp.last_match
type = (m[:type] || "").downcase
title = (m[:title] || "").strip
body = (m[:body] || "").gsub(/^>\s?/, '') # убираем ведущие '> '
meta = CALLOUTS[type] || {label: type.capitalize, css: type}
heading = title.empty? ? meta[:label] : title
%Q(
<div class="callout #{meta[:css]}">
<div class="callout-title">#{heading}</div>
<div class="callout-content">
#{body}
</div>
</div>
)
end
doc.content = content
end
end
end
+27
View File
@@ -12,3 +12,30 @@ body { line-height: 1.6; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
/* Callouts */
.callout {
margin: 1.25rem 0;
border-left: .35rem solid;
border-radius: .5rem;
padding: .85rem 1rem;
background: rgba(255,255,255,.03);
}
.callout-title {
font-weight: 700;
margin-bottom: .25rem;
}
.callout-content :last-child { margin-bottom: 0; }
/* Цвета по типам — подгоняй под свою палитру */
.callout.note { border-color: #8e9aa6; }
.callout.info { border-color: #00bcd4; }
.callout.tip { border-color: #7dd56f; }
.callout.success { border-color: #43a047; }
.callout.warning { border-color: #ffb74d; }
.callout.bug { border-color: #e57373; }
.callout.danger { border-color: #ef5350; }
.callout.quote { border-color: #9e9e9e; font-style: italic; }