From cd384b2cff6c17d10a15855081e8fc877a52c522 Mon Sep 17 00:00:00 2001 From: Vahid Al Date: Thu, 11 Jan 2024 13:17:22 +0330 Subject: [PATCH] Improve meta tags for social link preview --- script.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/script.py b/script.py index 7f17035..57fa928 100644 --- a/script.py +++ b/script.py @@ -39,13 +39,26 @@ for section in data["sections"] ) + meta_tags = frag( + h("title")(data.get("name")), + h("meta", name="description", content=data.get("description")), + h("meta", name="keywords", content=data.get("keywords")), + h("meta", name="viewport", content="width=device-width, initial-scale=1"), + h("meta", charset="utf-8"), + # OG + h("meta", name="og:title", content=data.get("name")), + h("meta", name="og:description", content=data.get("description")), + h("meta", name="og:image", content=f"img/{data.get('image')}"), + # Twitter / X + h("meta", name="twitter:title", content=data.get("name")), + h("meta", name="twitter:description", content=data.get("description")), + h("meta", name="twitter:image", content=f"img/{data.get('image')}"), + h("meta", name="twitter:card", content="summary_large_image"), + ) + head = frag( h("head")( - h("title")(data.get("name")), - h("meta", name="description", content=data.get("description")), - h("meta", name="keywords", content=data.get("keywords")), - h("meta", name="viewport", content="width=device-width, initial-scale=1"), - h("meta", charset="utf-8"), + meta_tags, h("link", rel="stylesheet", href="css/pico.min.css"), h("link", rel="stylesheet", href="css/style.css"), h("style", rel="stylesheet")(