Skip to content

Commit 30e09c6

Browse files
committed
添加head配置,用于配置自定义文章页head内容
1 parent a23cfe2 commit 30e09c6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Gmeek.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def cleanFile(self):
8888

8989

9090
def defaultConfig(self):
91-
dconfig={"singlePage":[],"startSite":"","filingNum":"","onePageListNum":15,"commentLabelColor":"#006b75","yearColorList":["#bc4c00", "#0969da", "#1f883d", "#A333D0"],"i18n":"CN","themeMode":"manual","dayTheme":"light","nightTheme":"dark","urlMode":"pinyin","script":"","style":"","indexScript":"","indexStyle":"","bottomText":"","showPostSource":1,"iconList":{},"UTC":+8,"rssSplit":"sentence","exlink":{},"needComment":1,"allHead":""}
91+
dconfig={"singlePage":[],"startSite":"","filingNum":"","onePageListNum":15,"commentLabelColor":"#006b75","yearColorList":["#bc4c00", "#0969da", "#1f883d", "#A333D0"],"i18n":"CN","themeMode":"manual","dayTheme":"light","nightTheme":"dark","urlMode":"pinyin","script":"","style":"","head":"","indexScript":"","indexStyle":"","bottomText":"","showPostSource":1,"iconList":{},"UTC":+8,"rssSplit":"sentence","exlink":{},"needComment":1,"allHead":""}
9292
config=json.loads(open('config.json', 'r', encoding='utf-8').read())
9393
self.blogBase={**dconfig,**config}.copy()
9494
self.blogBase["postListJson"]=json.loads('{}')
@@ -188,6 +188,7 @@ def createPostHtml(self,issue):
188188
postBase["commentNum"]=issue["commentNum"]
189189
postBase["style"]=issue["style"]
190190
postBase["script"]=issue["script"]
191+
postBase["head"]=issue["head"]
191192
postBase["top"]=issue["top"]
192193
postBase["postSourceUrl"]=issue["postSourceUrl"]
193194
postBase["repoName"]=options.repo_name
@@ -371,6 +372,11 @@ def addOnePostJson(self,issue):
371372
else:
372373
self.blogBase[listJsonName][postNum]["script"]=self.blogBase["script"]
373374

375+
if "head" in postConfig:
376+
self.blogBase[listJsonName][postNum]["head"]=self.blogBase["head"]+str(postConfig["head"])
377+
else:
378+
self.blogBase[listJsonName][postNum]["head"]=self.blogBase["head"]
379+
374380
if "ogImage" in postConfig:
375381
self.blogBase[listJsonName][postNum]["ogImage"]=postConfig["ogImage"]
376382
else:
@@ -478,6 +484,7 @@ def createFileName(self,issue,useLabel=False):
478484
del blog.blogBase["postListJson"][i]["createdAt"]
479485
del blog.blogBase["postListJson"][i]["script"]
480486
del blog.blogBase["postListJson"][i]["style"]
487+
del blog.blogBase["postListJson"][i]["head"]
481488
del blog.blogBase["postListJson"][i]["top"]
482489
del blog.blogBase["postListJson"][i]["ogImage"]
483490

templates/post.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<meta property="og:image" content="{{ blogBase['ogImage'] }}">
1010
<title>{{ blogBase['postTitle'] }}</title>
1111
{% if blogBase['highlight']==1 %}<link href="//unpkg.com/@wooorm/starry-night@2.1.1/style/both.css" rel="stylesheet" />{% endif %}
12+
{{ blogBase['head'] }}
1213
{% endblock %}
1314

1415
{% block style %}

0 commit comments

Comments
 (0)