From 5017d00a9a87b1e4f577c01d6ddd492ee1e995f3 Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Sat, 20 May 2023 11:56:53 +0200 Subject: Support Twitter cards and potentially more --- plugins/meta.lua | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++--- soupault.toml | 1 + templates/main.html | 10 ++++++++- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/plugins/meta.lua b/plugins/meta.lua index d16f6b7..449174d 100644 --- a/plugins/meta.lua +++ b/plugins/meta.lua @@ -1,9 +1,63 @@ -description = HTML.select_one(page, "#meta-tags .description") +base_url = config['site_base_url'] .. + soupault_config['widgets']['urls-rewriting']['prefix_url'] + +head = HTML.select_one(page, "head") + +title = HTML.select_one(page, 'h1') +if title then + HTML.append_child( + head, + HTML.parse( + '' + ) + ) + HTML.append_child( + head, + HTML.parse( + '' + ) + ) +end +HTML.append_child( + head, + HTML.parse( + '' + ) +) +HTML.append_child( + head, + HTML.parse( + '' + ) +) + +description = HTML.select_one(page, "#meta-tags .description") if description then description_contents = HTML.strip_tags(description) - head = HTML.select_one(page, "head") - HTML.append_child(head, HTML.parse('')) + description_contents = Regex.replace_all(description_contents, "\n", " ") + + HTML.append_child( + head, + HTML.parse( + '' + ) + ) + HTML.append_child( + head, + HTML.parse( + '' + ) + ) + HTML.append_child( + head, + HTML.parse( + '' + ) + ) else Log.warning("Missing description in " .. page_file) end diff --git a/soupault.toml b/soupault.toml index d536d4e..9cf3f41 100644 --- a/soupault.toml +++ b/soupault.toml @@ -65,6 +65,7 @@ [widgets.meta] after = "urls-rewriting" widget = "meta" + site_base_url = "https://soap.coffee/" [widgets.move-tags] widget = "move-tags" diff --git a/templates/main.html b/templates/main.html index db272a6..88b935e 100644 --- a/templates/main.html +++ b/templates/main.html @@ -1,4 +1,4 @@ - + @@ -6,6 +6,14 @@ + + + + + + + + -- cgit v1.2.3