ogImage字段添加到首页

This commit is contained in:
Meekdai 2024-04-09 13:45:29 +08:00
parent 98b8114b32
commit aaf6d1670f
2 changed files with 10 additions and 1 deletions

View File

@ -84,6 +84,9 @@ class GMEEK():
if "faviconUrl" not in self.blogBase:
self.blogBase["faviconUrl"]=self.blogBase["avatarUrl"]
if "ogImage" not in self.blogBase:
self.blogBase["ogImage"]=self.blogBase["avatarUrl"]
if "homeUrl" not in self.blogBase:
if str(self.repo.name) == (str(self.repo.owner.login)+".github.io"):
self.blogBase["homeUrl"] = f"https://{self.repo.name}"
@ -328,7 +331,7 @@ class GMEEK():
if "ogImage" in postConfig:
self.blogBase[listJsonName][postNum]["ogImage"]=postConfig["ogImage"]
else:
self.blogBase[listJsonName][postNum]["ogImage"]=self.blogBase["avatarUrl"]
self.blogBase[listJsonName][postNum]["ogImage"]=self.blogBase["ogImage"]
thisTime=datetime.datetime.fromtimestamp(self.blogBase[listJsonName][postNum]["createdAt"])
thisTime=thisTime.astimezone(self.TZ)
@ -433,6 +436,7 @@ for i in blog.blogBase["postListJson"]:
del blog.blogBase["postListJson"][i]["script"]
del blog.blogBase["postListJson"][i]["style"]
del blog.blogBase["postListJson"][i]["top"]
del blog.blogBase["postListJson"][i]["ogImage"]
if 'commentNum' in blog.blogBase["postListJson"][i]:
commentNumSum=commentNumSum+blog.blogBase["postListJson"][i]["commentNum"]

View File

@ -1,6 +1,11 @@
{% extends 'base.html' %}
{% block head %}
<meta name="description" content="{{ blogBase['subTitle'] }}">
<meta property="og:title" content="{{ blogBase['title'] }}">
<meta property="og:description" content="{{ blogBase['subTitle'] }}">
<meta property="og:type" content="blog">
<meta property="og:url" content="{{ blogBase['homeUrl'] }}">
<meta property="og:image" content="{{ blogBase['ogImage'] }}">
<title>{{ blogBase['title'] }}</title>
{% endblock %}