diff --git a/.github/workflows/hugo_publisher.yml b/.github/workflows/hugo_publisher.yml index 2b672378..3dbbff9b 100644 --- a/.github/workflows/hugo_publisher.yml +++ b/.github/workflows/hugo_publisher.yml @@ -36,7 +36,7 @@ jobs: name: Install dependencies runs-on: ubuntu-latest env: - HUGO_VERSION: 0.146.1 + HUGO_VERSION: 0.146.4 steps: - name: Install Hugo CLI run: | diff --git a/make-post.py b/make-post.py index 64f070a6..8b1400cc 100644 --- a/make-post.py +++ b/make-post.py @@ -1,31 +1,38 @@ import datetime import os +import re + + +def name_cleaning(name: str) -> str: + + title = re.sub("[^A-Za-z0-9 ]+", " ", name) + title = title.replace(" ", " ") + title = title.replace(" ", "-") + title = title.lower() + return title def post_photo(): # get the current year as variable year = str(datetime.datetime.now().year) name = input("Give me the title\n") - os.system( - f"hugo new photos/{year}/{name.replace(' ', '-').replace(',', '').lower()}/index.md" - ) + title = name_cleaning(name) + os.system(f"hugo new photos/{year}/{title}/index.md") def post_redirect(): # get the current year as variable name = input("Give me the title\n") - os.system( - f"hugo new redirect/{name.replace(' ', '-').replace(',', '').lower()}/index.md" - ) + title = name_cleaning(name) + os.system(f"hugo new redirect/{title}/index.md") def post_fc(): # get the current year as variable year = str(datetime.datetime.now().year) name = input("Give me the title\n") - os.system( - f"hugo new post/{year}/{name.replace(' ', '-').replace(',', '').lower()}/index.md" - ) + title = name_cleaning(name) + os.system(f"hugo new post/{year}/{title}/index.md") def micro_fc(): @@ -33,7 +40,9 @@ def micro_fc(): name = input("Give me the title\n") year = str(datetime.datetime.now().year) month = str(datetime.datetime.now().month) - generated = f"{year.ljust(4, "0")}/{month.ljust(2, "0")}/{name.replace(' ', '-').replace(',', '').lower()}" + title = name_cleaning(name) + + generated = f"{year.ljust(4, "0")}/{month.ljust(2, "0")}/{title}" os.system(f"hugo new micro/{generated}/index.md") print(f"Generated {generated}/index.md")