fix: Update cleanSite hook to clean now page html files
All checks were successful
Build Docker / BuildImage (push) Successful in 1m9s

This commit is contained in:
2025-01-04 20:11:35 +11:00
parent f9b30a3fe6
commit 7896f71534
22 changed files with 60 additions and 51 deletions

View File

@@ -1,29 +1,36 @@
import os
# Read all files in the templates directory
for file in os.listdir('templates'):
def cleanSite(path:str):
# Check if the file is sitemap.xml
if file == 'sitemap.xml':
if path.endswith('sitemap.xml'):
# Open the file
with open('templates/sitemap.xml', 'r') as f:
with open(path, 'r') as f:
# Read the content
content = f.read()
# Replace all .html with empty string
content = content.replace('.html', '')
# Write the content back to the file
with open('templates/sitemap.xml', 'w') as f:
with open(path, 'w') as f:
f.write(content)
# Skip the file
continue
return
# If the file is not an html file, skip it
if not file.endswith('.html'):
continue
if not path.endswith('.html'):
if os.path.isdir(path):
for file in os.listdir(path):
cleanSite(path + '/' + file)
return
# Open the file
with open('templates/' + file, 'r') as f:
with open(path, 'r') as f:
# Read and remove all .html
content = f.read().replace('.html"', '"')
# Write the cleaned content back to the file
with open('templates/' + file, 'w') as f:
f.write(content)
with open(path, 'w') as f:
f.write(content)
for file in os.listdir('templates'):
cleanSite('templates/' + file)