Update Hugo version and refactor post creation functions to use name cleaning

This commit is contained in:
Fundor333
2025-04-14 15:28:53 +02:00
parent 09f4dd4a44
commit fe91cef96d
2 changed files with 20 additions and 11 deletions

View File

@@ -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: |

View File

@@ -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")