From d27c5ff896d63aa08d36b5b54be12b68ebd21e98 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 23 May 2025 15:17:31 +0800 Subject: fix: link-graph.json cannot be found Former-commit-id: d69e53b588ab131309c75c602e28c741ab5641a9 --- extractLinks.py | 12 +++++------- 1 file 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__": -- cgit v1.2.3