summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-05-23 15:20:57 +0800
committerEltrac <hi@guhub.cn>2025-05-23 15:20:57 +0800
commitf7b18b6e4edc1ea4693b0ae3ae8292a4ad4f8ab3 (patch)
tree707288d1273e9143628b2c6b68f52ffd5201af5e
parentd69e53b588ab131309c75c602e28c741ab5641a9 (diff)
fix: invalid nodes data
-rw-r--r--extractLinks.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/extractLinks.py b/extractLinks.py
index e1eaf2e3..eb172353 100644
--- a/extractLinks.py
+++ b/extractLinks.py
@@ -166,7 +166,11 @@ def main():
collect_urls()
build_link_graph()
- nodes = [{"id": url, "label": label_map.get(url, url.strip("/").split("/")[-1]), "url": url} for url in link_graph]
+ nodes = [
+ {"id": url, "label": title_map[url], "url": url}
+ for url in link_graph
+ ]
+
edges = []
for source, targets in link_graph.items():
for target in targets:
@@ -174,12 +178,10 @@ def main():
graph = {"nodes": nodes, "edges": edges}
- # ✅ 写入到 public/
output_path = os.path.join("public", "link-graph.json")
with open(output_path, "w", encoding="utf-8") as f:
json.dump(graph, f, indent=2, ensure_ascii=False)
print(f"✅ Link graph generated: {output_path}")
-
if __name__ == "__main__":
main()