diff --git a/glee.py b/glee.py
index 38ded6d..7ce8ad1 100644
--- a/glee.py
+++ b/glee.py
@@ -16,6 +16,7 @@
from bs4 import BeautifulSoup
import os
import shutil
+import json
from datetime import datetime as date
from handle_config import (
@@ -264,9 +265,10 @@ def post_to_ghost(meta, md):
)
return
-
+ inject_multi_titles(meta)
meta = add_blog_configurations(meta)
meta["html"] = to_html(md)
+
token = get_jwt()
headers = {"Authorization": "Ghost {}".format(token)}
@@ -301,12 +303,12 @@ def add_blog_configurations(meta):
theme = select_codehilite_theme(code_theme)
if side_bar_toc:
- meta["codeinjection_head"] = (
+ meta["codeinjection_head"] += (
f"""""" + sidebar_toc_head
)
meta["codeinjection_foot"] = sidebar_toc_footer
else:
- meta["codeinjection_head"] = f""""""
+ meta["codeinjection_head"] += f""""""
return meta
@@ -314,6 +316,48 @@ def add_blog_configurations(meta):
sys.exit(f"""Error: {e}""")
+def inject_multi_titles(meta):
+ meta["codeinjection_head"] = ""
+ try:
+ title_data = meta["title"]
+
+ if isinstance(title_data, str): # Title is a string
+ pass
+ elif isinstance(title_data, dict): # Title is a dictionary
+ default_title = title_data.get("default")
+
+ if "default" not in title_data:
+ raise KeyError("Missing 'default' key in title_data")
+
+ meta["title"] = default_title
+
+ title_data_str = json.dumps(title_data)
+
+ meta[
+ "codeinjection_head"
+ ] = f""""""
+
+ except KeyError:
+ sys.exit(f"""Error: missing default title""")
+
+ except Exception as e:
+ logging.error("error in title updating", e)
+ pass
+
+
if __name__ == "__main__":
post = frontmatter.load(args.markdown_file)
post_to_ghost(post.metadata, post.content)
diff --git a/sample_post.md b/sample_post.md
index 208dbdd..82bc14c 100644
--- a/sample_post.md
+++ b/sample_post.md
@@ -1,11 +1,15 @@
---
-title: 'testing sample markdown file'
+title:
+ default: new default title
+ hn: title from glee to HN
+ reddit: title from glee to reddit
+
authors:
- sample@gmail.com
tags: ["draft"]
featured: false
status: draft
-custom_excerpt: This is a customexcerpt
+custom_excerpt: This is a custom excerpt
feature_image: ./test_images/Animhorse.gif
# sidebar_toc: false
# code_hilite_theme: vim
@@ -262,4 +266,45 @@ def hello_world():
-
\ No newline at end of file
+
+
+
+
+
+
+
\ No newline at end of file