diff --git a/src/views/general.nim b/src/views/general.nim index e1ed4da..abcf45c 100644 --- a/src/views/general.nim +++ b/src/views/general.nim @@ -89,15 +89,16 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc=""; text cfg.title let finalizedTitleText = (if ogTitle.len > 0: ogTitle else: titleText) + let finalizedDesc = stripHtml(desc) meta(name="viewport", content="width=device-width, initial-scale=1.0") meta(name="theme-color", content="#1F1F1F") meta(property="og:type", content=ogType) - if video.len > 0: - meta(property="og:title", content=stripHtml(desc)) + if video.len > 0 and len(finalizedDesc) <= 67: + meta(property="og:title", content=finalizedDesc) else: meta(property="og:title", content=finalizedTitleText) - meta(property="og:description", content=stripHtml(desc)) + meta(property="og:description", content=finalizedDesc) meta(property="og:site_name", content="Nitter") meta(property="og:locale", content="en_US") @@ -114,7 +115,6 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc=""; meta(property="og:image", content=image) if video.len == 0: meta(property="twitter:image:src", content=image) - if rss.len > 0: meta(property="twitter:card", content="summary") elif video.len == 0: @@ -124,7 +124,13 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc=""; meta(property="og:video:url", content=video) meta(property="og:video:secure_url", content=video) meta(property="og:video:type", content="video/mp4") - verbatim &"" + var title = encodeUrl(finalizedDesc) + var author = encodeUrl(finalizedTitleText) + if len(finalizedDesc) > 67: + title = author + author = encodeUrl(finalizedDesc) + + verbatim &"" #link(rel="alternate", # href=&"{getUrlPrefix(cfg)}/oembed.json?type=video&title={encodeUrl(stripHtml(desc))}&user={encodeUrl(finalizedTitleText)}&url={encodeUrl(req.path)}", # `type`="application/json+oembed")