Modified ssg5 to support og:title and twitter:title tags for better integration

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2021-03-19 09:07:49 +01:00
parent 34dc81c5af
commit 095d3dc2a2
2 changed files with 14 additions and 6 deletions

View File

@ -16,16 +16,16 @@ PAGE CODED BY :
<link rel="icon" href="/assets/images/qr_code.png">
<!-- SEO -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Ceci est le blog de Louis Vallat.">
<meta name="description" content="Un article disponible sur le blog de Louis Vallat.">
<meta name="image" content="https://blog.louis-vallat.xyz/assets/images/qr_code.png">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Le blog de Louis Vallat">
<meta name="twitter:description" content="Ceci est le blog de Louis Vallat.">
<meta name="twitter:title" content="">
<meta name="twitter:description" content="Un article disponible sur le blog de Louis Vallat.">
<meta name="twitter:site" content="@VallatLouis">
<meta name="twitter:creator" content="@VallatLouis">
<meta name="twitter:image:src" content="https://blog.louis-vallat.xyz/assets/images/qr_code.png">
<meta name="og:title" content="Le blog de Louis Vallat">
<meta name="og:description" content="Ceci est le blog de Louis Vallat.">
<meta name="og:title" content="">
<meta name="og:description" content="Un article disponible sur le blog de Louis Vallat.">
<meta name="og:image" content="https://blog.louis-vallat.xyz/assets/images/qr_code.png">
<meta name="og:url" content="https://blog.louis-vallat.xyz/">
<meta name="og:site_name" content="Le blog de Louis Vallat">

10
ssg5
View File

@ -228,7 +228,15 @@ render_html_file() {
}
n = split(ENVIRON["HEADER"], header, /\n/)
for (i = 1; i <= n; i++) {
if (match(tolower(header[i]), "<title></title>")) {
if (match(tolower(header[i]), "<meta name=\"twitter:title\" content=\"\">")) {
head = substr(header[i], 1, RSTART - 1)
tail = substr(header[i], RSTART + RLENGTH)
print head "<meta name=\"twitter:title\" content=\"" title "\">" tail
} else if (match(tolower(header[i]), "<meta name=\"og:title\" content=\"\">")) {
head = substr(header[i], 1, RSTART - 1)
tail = substr(header[i], RSTART + RLENGTH)
print head "<meta name=\"og:title\" content=\"" title "\">" tail
} else if (match(tolower(header[i]), "<title></title>")) {
head = substr(header[i], 1, RSTART - 1)
tail = substr(header[i], RSTART + RLENGTH)
print head "<title>" title "</title>" tail