mirror of
https://github.com/ada-dmitry/ada-dmitry.github.io.git
synced 2026-09-24 09:20:40 +00:00
Добавить плагин для генерации графа заметок: создать файл graph_json.rb для визуализации связей между заметками
This commit is contained in:
+1
-1
@@ -94,7 +94,7 @@ obsidian:
|
||||
slugify: true # заменять пробелы/кириллицу на слаг
|
||||
ext: ".md"
|
||||
attachments_dir: "assets/cache/"
|
||||
graph: true
|
||||
# graph: true
|
||||
|
||||
# --- Навигация (подключим _data/navigation.yml) ---
|
||||
navigation:
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
require 'json'
|
||||
|
||||
Jekyll::Hooks.register :site, :post_write do |site|
|
||||
notes = site.collections["notes"].docs
|
||||
nodes = []
|
||||
edges = []
|
||||
|
||||
notes.each do |note|
|
||||
id = note.url
|
||||
nodes << { id: id, title: note.data["title"] || note.basename_without_ext, url: note.url }
|
||||
|
||||
# ищем [[ссылки]]
|
||||
note.content.scan(/\[\[(.*?)\]\]/).each do |m|
|
||||
target = m[0].downcase.strip.gsub(" ", "-")
|
||||
target_doc = notes.find { |n| n.basename_without_ext.downcase == target }
|
||||
edges << { source: id, target: target_doc.url } if target_doc
|
||||
end
|
||||
end
|
||||
|
||||
graph = { nodes: nodes, edges: edges }
|
||||
File.write(File.join(site.dest, "graph.json"), JSON.pretty_generate(graph))
|
||||
end
|
||||
Reference in New Issue
Block a user