From 70d02250b50b87d7d6c4775ebe256ac4a7d3e21f Mon Sep 17 00:00:00 2001 From: arlowatts Date: Wed, 22 May 2024 14:36:25 -0700 Subject: [PATCH] Update link fix --- scripts/content.py | 12 +++++++----- scripts/index.py | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/content.py b/scripts/content.py index 7ca87a2..7859fb0 100644 --- a/scripts/content.py +++ b/scripts/content.py @@ -4,11 +4,13 @@ def main(): # add the front matter content = "---\ntitle: Table of Contents\n---\n" - content += read("world/adventures") - content += read("world/locations") - content += read("world/races") + os.chdir("world") - with open("world/content.md", "w") as file: + content += read("adventures") + content += read("locations") + content += read("races") + + with open("content.md", "w") as file: file.write(content) # recursively list files in the given directory @@ -41,7 +43,7 @@ def getDirEntry(path: str, depth: int = 0): # get the table of contents line for this path, given the recursion depth def getFileEntry(path: str, depth: int = 0): - return " " * (depth - 1) + "- [" + getFileTitle(path) + "](/torys/" + path + ")\n" + return " " * (depth - 1) + "- [" + getFileTitle(path) + "](" + path + ")\n" # get the title from the contents or name of the directory # if the directory contains index.md, the title will be inherited from it diff --git a/scripts/index.py b/scripts/index.py index 2fca942..18d7d0c 100644 --- a/scripts/index.py +++ b/scripts/index.py @@ -6,9 +6,11 @@ def main(): index = {} - read("world/adventures", index) - read("world/locations", index) - read("world/races", index) + os.chdir("world") + + read("adventures", index) + read("locations", index) + read("races", index) letter = "@" @@ -24,7 +26,7 @@ def main(): for entry in index[key]: content += " - " + entry + "\n" - with open("world/index.md", "w") as file: + with open("index.md", "w") as file: file.write(content) # recursively search files in the given directory @@ -60,7 +62,7 @@ def getFileEntries(path: str, index: dict): index[key] = [] # assemble the jumplink to the current location - link = "[" + pageTitle + headerTitle + "](/torys/" + path + urlKey + ")" + link = "[" + pageTitle + headerTitle + "](" + path + urlKey + ")" # add the current path to the phrase if it isn't there already if not link in index[key]: