summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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__":