Update Hugo version and refactor post creation functions to use name cleaning
This commit is contained in:
2
.github/workflows/hugo_publisher.yml
vendored
2
.github/workflows/hugo_publisher.yml
vendored
@@ -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: |
|
||||
|
||||
29
make-post.py
29
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")
|
||||
|
||||
Reference in New Issue
Block a user