diff --git a/_config.yml b/_config.yml index ce398d3..80378f4 100644 --- a/_config.yml +++ b/_config.yml @@ -8,6 +8,9 @@ favicon: /assets/images/favicons/favicon.ico locale: ru +sass: + style: compressed + analytics: provider: "google-gtag" # встроенная интеграция google: diff --git a/_plugins/callouts.rb b/_plugins/callouts.rb new file mode 100644 index 0000000..0482b5c --- /dev/null +++ b/_plugins/callouts.rb @@ -0,0 +1,54 @@ +# _plugins/obsidian_callouts.rb +# Конвертирует Obsidian callouts ( > [!type] title ... ) +# в HTML блоки .callout. + +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*\[!(?[A-Za-z_-]+)\]\s*(?[^\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 diff --git a/assets/css/main.scss b/assets/css/main.scss index 3040da0..99bdc64 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -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; } \ No newline at end of file