client: set og:url to the request_uri

This commit is contained in:
Ben Klein 2021-07-10 00:21:13 -04:00
parent 44d28f3f63
commit b4851ce32c
2 changed files with 5 additions and 3 deletions

View file

@ -17,11 +17,12 @@ local server_info = cjson.decode((ngx.location.capture("/_internal_api/info")).b
local additional_tags = "" local additional_tags = ""
local function add_meta_tag (property, content) local function add_meta_tag (property, content)
additional_tags = additional_tags .. "<meta property=\"" .. property .. "\" content=\"" .. content:gsub('"', '\\"') .. "\" />" additional_tags = additional_tags .. "<meta property=\"" .. property .. "\" content=\"" .. content:gsub('"', '\\"') .. "\"/>"
end end
-- Add the site name tag -- Add the site name tag
add_meta_tag("og:site_name", server_info.config.name) add_meta_tag("og:site_name", server_info.config.name)
add_meta_tag("og:url", ngx.var.scheme .. "://" .. ngx.var.http_host .. ngx.var.request_uri)
local final_response = page_html.body:gsub("{{ generated_head_tags }}", additional_tags) local final_response = page_html.body:gsub("{{ generated_head_tags }}", additional_tags)

View file

@ -81,7 +81,7 @@ http {
location / { location / {
root /var/www; root /var/www;
try_files $uri /_og_tags_html; try_files $uri /_meta_tags_html;
sendfile on; sendfile on;
tcp_nopush on; tcp_nopush on;
@ -104,7 +104,8 @@ http {
proxy_pass http://backend/$1; proxy_pass http://backend/$1;
} }
location /_og_tags_html { location /_meta_tags_html {
internal;
root /var/www; root /var/www;
content_by_lua_file /etc/nginx/metatags.lua; content_by_lua_file /etc/nginx/metatags.lua;
} }