添加Open Graph协议内容,让分享博客链接有预览

This commit is contained in:
Meekdai 2024-04-09 09:57:37 +08:00
parent bd75753a73
commit 91dacffe12
2 changed files with 12 additions and 1 deletions

View File

@ -136,6 +136,11 @@ class GMEEK():
issue["script"]=issue["script"]+'<script>MathJax = {tex: {inlineMath: [["$", "$"]]}};</script><script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>'
postBase["postTitle"]=issue["postTitle"]
postBase["postUrl"]=self.blogBase["homeUrl"]+"/"+issue["postUrl"]
postBase["description"]=issue["description"]
postBase["createdDate"]=issue["createdDate"]
postBase["author"]=self.blogBase["title"]
postBase["avatarUrl"]=self.blogBase["avatarUrl"]
postBase["postBody"]=post_body
postBase["commentNum"]=issue["commentNum"]
postBase["style"]=issue["style"]

View File

@ -1,7 +1,13 @@
{% extends 'base.html' %}
{% block head %}
<meta name="description" content="{{ blogBase['postTitle'] }}">
<meta name="description" content="{{ blogBase['description'] }}">
<meta property="og:title" content="{{ blogBase['postTitle'] }}">
<meta property="og:type" content="article">
<meta property="og:url" content="{{ blogBase['postUrl'] }}">
<meta property="og:image" content="{{ blogBase['avatarUrl'] }}" />
<meta property="article:published_time" content="{{ blogBase['createdDate'] }}">
<meta property="article:author" content="{{ blogBase['author'] }}">
<title>{{ blogBase['postTitle'] }}</title>
{% if blogBase['highlight']==1 %}<link href="//unpkg.com/@wooorm/starry-night@2.1.1/style/both.css" rel="stylesheet" />{% endif %}
{% endblock %}