Index

joshstock.in / master

Source for serving and static templating/compiling of https://joshstock.in.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
19921 Dec 2023 15:250fe4f18Add author meta tag to blog articlesJosh Stockin121G

Blob @ joshstock.in / site / generators / head / meta.py

application/x-python1945 bytesdownload raw
1from .._variables import verify
2import htmlgenerator as hg
3
4
5def run(data):
6 """Build HTML meta tags and insert tracking script"""
7
8 verify(data, ["type", "title", "description", "thumbnail", "link"])
9
10 contents = [
11 hg.META(http_equiv="content-type", content="text/html; charset=utf-8"),
12 hg.META(name="format-detection", content="telephone=no,date=no,address=no,email=no,url=no"),
13 hg.TITLE(f"{data.title} - Josh Stockin"),
14 hg.META(name="title", content=f"{data.title} - Josh Stockin"),
15 hg.META(name="description", content=data.description),
16 hg.META(name="author", content="Josh Stockin") if data.type == "article" else "",
17
18 # OG tags
19 hg.META(property="og:site_name", content="Josh Stockin"),
20 hg.META(property="og:title", content=f"{data.title} - Josh Stockin"),
21 hg.META(property="og:description", content=data.description),
22 hg.META(property="og:type", content="website"),
23 hg.META(
24 property="og:image",
25 content=data.thumbnail if not data.thumbnail.startswith("/") else f"https://joshstock.in{data.thumbnail}"
26 if data.thumbnail != ""
27 else "https://joshstock.in/static/images/river.jpg",
28 ),
29 hg.META(property="og:url", content=f"https://joshstock.in{data.link}"),
30
31 # Twitter card
32 hg.META(name="twitter:card", content="summary_large_image"),
33 hg.META(name="twitter:creator", content="@JoshStockin"),
34 hg.META(name="twitter:title", content=f"{data.title} - Josh Stockin"),
35 hg.META(name="twitter:description", content=data.description),
36 hg.META(
37 name="twitter:image",
38 content=data.thumbnail if not data.thumbnail.startswith("/") else f"https://joshstock.in{data.thumbnail}"
39 if data.thumbnail != ""
40 else "https://joshstock.in/static/images/river.jpg",
41 ),
42 ]
43
44 return contents
45