summaryrefslogtreecommitdiffstats
path: root/plugins/meta.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/meta.lua')
-rw-r--r--plugins/meta.lua60
1 files changed, 57 insertions, 3 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(
+ '<meta property="og:title" content="' .. HTML.strip_tags(title) .. '" />'
+ )
+ )
+ HTML.append_child(
+ head,
+ HTML.parse(
+ '<meta name="twitter:title" content="' .. HTML.strip_tags(title) .. '" />'
+ )
+ )
+end
+HTML.append_child(
+ head,
+ HTML.parse(
+ '<meta property="og:url" content ="' .. base_url .. page_url .. '" />'
+ )
+)
+HTML.append_child(
+ head,
+ HTML.parse(
+ '<meta property="twitter:url" content ="' .. base_url .. page_url .. '" />'
+ )
+)
+
+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('<meta name="description" content="' .. description_contents .. '">'))
+ description_contents = Regex.replace_all(description_contents, "\n", " ")
+
+ HTML.append_child(
+ head,
+ HTML.parse(
+ '<meta name="description" content="'
+ .. description_contents .. '">'
+ )
+ )
+ HTML.append_child(
+ head,
+ HTML.parse(
+ '<meta property="og:description" content="'
+ .. description_contents .. '">'
+ )
+ )
+ HTML.append_child(
+ head,
+ HTML.parse(
+ '<meta name="twitter:description" content="'
+ .. description_contents .. '">'
+ )
+ )
else
Log.warning("Missing description in " .. page_file)
end