summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-05-23 15:17:31 +0800
committerEltrac <hi@guhub.cn>2025-05-23 15:17:31 +0800
commitd69e53b588ab131309c75c602e28c741ab5641a9 (patch)
tree417b461ecdf45d51f2c83b594cf416c6a6d5efab
parentc26a41cc8ec6bd7baec37d17780ec757759c53f2 (diff)
fix: link-graph.json cannot be found
-rw-r--r--extractLinks.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/extractLinks.py b/extractLinks.py
index 8cd7695c..e1eaf2e3 100644
--- a/extractLinks.py
+++ b/extractLinks.py
@@ -166,11 +166,7 @@ def main():
collect_urls()
build_link_graph()
- nodes = [
- {"id": url, "label": title_map[url], "url": url}
- for url in link_graph
- ]
-
+ nodes = [{"id": url, "label": label_map.get(url, url.strip("/").split("/")[-1]), "url": url} for url in link_graph]
edges = []
for source, targets in link_graph.items():
for target in targets:
@@ -178,9 +174,11 @@ def main():
graph = {"nodes": nodes, "edges": edges}
- with open("static/link-graph.json", "w", encoding="utf-8") as f:
+ # ✅ 写入到 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("✅ Link graph generated: link-graph.json")
+ print(f"✅ Link graph generated: {output_path}")
if __name__ == "__main__":