From 40f5d4df331667909c2fbad90ad734b782975ca0 Mon Sep 17 00:00:00 2001 From: Alex <53612685+apotenza92@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:54:44 +1100 Subject: [PATCH] Updated blog --- content/posts/Bypass Paywalls.md | 17 +------- hugo.toml | 9 ++--- public/robots.txt | 3 ++ update_blog.py | 69 ++++++-------------------------- 4 files changed, 20 insertions(+), 78 deletions(-) create mode 100644 public/robots.txt diff --git a/content/posts/Bypass Paywalls.md b/content/posts/Bypass Paywalls.md index ea647ae..2db5800 100755 --- a/content/posts/Bypass Paywalls.md +++ b/content/posts/Bypass Paywalls.md @@ -1,21 +1,6 @@ --- title: Bypass Paywalls -date: "2025-01-17T14:13:00+11:00" -ShowBreadCrumbs: True -ShowPostNavLinks: True -ShowReadingTime: True -ShowRssButtonInSectionTermList: True -ShowWordCount: True -TocOpen: False -UseHugoToc: True -comments: False -disableHLJS: False -disableShare: False -draft: False -hideSummary: False -hidemeta: False -searchHidden: True -showToc: True +date: 2025-01-17T14:13:00+11:00 --- ## Introduction diff --git a/hugo.toml b/hugo.toml index e65c0f6..4b1d493 100644 --- a/hugo.toml +++ b/hugo.toml @@ -3,10 +3,6 @@ languageCode = 'en-au' title = "Alex's Blog" theme = "PaperMod" -## Change default post kind -[archetypes] -default = "papermod" - ## Papermod theme options enableRobotsTXT = true buildDrafts = false @@ -41,8 +37,11 @@ disableScrollToTop = false comments = false hidemeta = false hideSummary = false -showtoc = false +showtoc = true tocopen = false +disableHLJS = false +disableShare = false +searchHidden = true [params.assets] favicon = "" diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..358ff84 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +User-agent: * +Disallow: +Sitemap: https://apotenza92.github.io/blog/sitemap.xml diff --git a/update_blog.py b/update_blog.py index c9c11be..739f078 100644 --- a/update_blog.py +++ b/update_blog.py @@ -231,7 +231,7 @@ def format_date(date_str): def sync_posts(paths): """Sync posts from Obsidian to Hugo and merge frontmatter""" try: - # First sync the files - same as before + # Sync the files subprocess.run( [ "rsync", @@ -243,28 +243,7 @@ def sync_posts(paths): check=True, ) - # Define field order (title and date first, then alphabetical) - field_order = ["title", "date"] - - required_fields = { - "showToc": True, - "TocOpen": False, - "draft": False, - "hidemeta": False, - "comments": False, - "disableHLJS": False, - "disableShare": False, - "hideSummary": False, - "searchHidden": True, - "ShowReadingTime": True, - "ShowBreadCrumbs": True, - "ShowPostNavLinks": True, - "ShowWordCount": True, - "ShowRssButtonInSectionTermList": True, - "UseHugoToc": True, - } - - # Then process each markdown file + # Process each markdown file for filename in os.listdir(paths["hugo"]["posts"]): if not filename.endswith(".md"): continue @@ -281,7 +260,7 @@ def sync_posts(paths): body = parts[2] # Parse existing frontmatter - existing_fields = {} + fields = {} for line in frontmatter.strip().split("\n"): if ":" in line: key, value = line.split(":", 1) @@ -297,44 +276,20 @@ def sync_posts(paths): key = "date" value = format_date(value) - existing_fields[key] = value + fields[key] = value - # First create merged fields - merged_fields = {**required_fields, **existing_fields} - - # Create ordered fields dictionary - ordered_fields = {} - - # First add title and date if they exist - for field in field_order: - if field in merged_fields: - ordered_fields[field] = merged_fields[field] - if field == "date": # Ensure date is properly quoted - if not ordered_fields[field].startswith('"'): - ordered_fields[field] = f'"{ordered_fields[field]}"' - - # Add remaining fields alphabetically - for key in sorted(merged_fields.keys()): - if ( - key not in ordered_fields - ): # Use ordered_fields instead of field_order - ordered_fields[key] = merged_fields[key] - - # Create new frontmatter + # Create new frontmatter with just title and date new_frontmatter = "---\n" - new_frontmatter += "\n".join( - f"{k}: {v}" for k, v in ordered_fields.items() - ) - new_frontmatter += "\n---" + if "title" in fields: + new_frontmatter += f"title: {fields['title']}\n" + if "date" in fields: + new_frontmatter += f"date: {fields['date']}\n" + new_frontmatter += "---" content = f"{new_frontmatter}{body}" + else: # No frontmatter - new_frontmatter = "---\n" - new_frontmatter += "\n".join( - f"{k}: {v}" for k, v in required_fields.items() - ) - new_frontmatter += "\n---\n\n" - content = new_frontmatter + content + content = "---\n---\n\n" + content # Write the modified content back with open(filepath, "w") as file: