Skip to content

Commit

Permalink
Update link fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arlowatts committed May 22, 2024
1 parent 7726f92 commit 70d0225
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions scripts/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions scripts/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "@"

Expand All @@ -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
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit 70d0225

Please sign in to comment.