Skip to content

Commit

Permalink
Update generate-home-buttons.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler887 authored Apr 13, 2022
1 parent 13ff059 commit 315daa1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions generate-home-buttons.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import os, glob
from colorama import *
def addhome(page):
def addhome(page, entry=False):
try:
if os.path.isfile(page):
with open(page, "a+") as file:
if page.endswith(".md"):
file.write(f"\n\n[<div align=\"center\"><sub><i><< Back to home...</i></sub></div>](/typoqsuat)")
if entry:
file.write(f"\n\n[<sub><i><< Back to home...</i></sub>](/typoqsuat) <sub>|</sub> [<sub><i>YAML source...</i></sub>](https://github.com/Tyler887/typoqsuat/blob/main/api/entry/{os.path.basename(page).replace('.md','.yaml')})")
else:
file.write(f"\n\n[<sub><i><< Back to home...</i></sub>](/typoqsuat)")
print(f"{Fore.GREEN}Added{Style.RESET_ALL} home button to {file}!\n")
else:
print(f"{Fore.YELLOW}Skipped{Style.RESET_ALL} {file}.\n")
Expand All @@ -18,6 +21,6 @@ def addhome(page):
print(f"{Fore.BLUE}>>>{Style.RESET_ALL} Generating home buttons for entries.")

for i in glob.glob(f"{os.getcwd()}/typo/*"):
addhome(i)
addhome(i, entry=True)

print("Generated home buttons!")

0 comments on commit 315daa1

Please sign in to comment.