| 1 | from .._variables import verify |
| 2 | import htmlgenerator as hg |
| 3 |
|
| 4 |
|
| 5 | def run(data): |
| 6 | """Build HTML meta tags and insert tracking script""" |
| 7 |
|
| 8 | verify(data, ["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 |
|
| 17 | # OG tags |
| 18 | hg.META(property="og:site_name", content="Josh Stockin"), |
| 19 | hg.META(property="og:title", content=f"{data.title} - Josh Stockin"), |
| 20 | hg.META(property="og:description", content=data.description), |
| 21 | hg.META(property="og:type", content="website"), |
| 22 | hg.META( |
| 23 | property="og:image", |
| 24 | content=data.thumbnail if not data.thumbnail.startswith("/") else f"https://joshstock.in{data.thumbnail}" |
| 25 | if data.thumbnail != "" |
| 26 | else "https://joshstock.in/static/images/river.jpg", |
| 27 | ), |
| 28 | hg.META(property="og:url", content=f"https://joshstock.in{data.link}"), |
| 29 |
|
| 30 | # Twitter card |
| 31 | hg.META(name="twitter:card", content="summary_large_image"), |
| 32 | hg.META(name="twitter:creator", content="@JoshStockin"), |
| 33 | hg.META(name="twitter:title", content=f"{data.title} - Josh Stockin"), |
| 34 | hg.META(name="twitter:description", content=data.description), |
| 35 | hg.META( |
| 36 | name="twitter:image", |
| 37 | content=data.thumbnail if not data.thumbnail.startswith("/") else f"https://joshstock.in{data.thumbnail}" |
| 38 | if data.thumbnail != "" |
| 39 | else "https://joshstock.in/static/images/river.jpg", |
| 40 | ), |
| 41 | ] |
| 42 |
|
| 43 | return contents |
| 44 |
|