client: initial og:title and og:image for posts
This commit is contained in:
parent
1f3c6ca35f
commit
7d90a73b11
2 changed files with 12 additions and 2 deletions
|
@ -22,7 +22,13 @@ end
|
|||
|
||||
-- Add the site name tag
|
||||
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)
|
||||
add_meta_tag("og:url", ngx.var.external_host_url .. ngx.var.request_uri)
|
||||
|
||||
if ngx.var.request_uri_path:match('^/post') then
|
||||
local post_info = cjson.decode((ngx.location.capture("/_internal_api"..ngx.var.request_uri_path)).body)
|
||||
add_meta_tag("og:image", ngx.var.external_host_url .. '/' .. post_info.contentUrl)
|
||||
add_meta_tag("og:title", server_info.config.name .. " - Post " .. post_info.id)
|
||||
end
|
||||
|
||||
local final_response = page_html.body:gsub("{{ generated_head_tags }}", additional_tags)
|
||||
|
||||
|
|
|
@ -25,9 +25,12 @@ http {
|
|||
server __BACKEND__:6666;
|
||||
}
|
||||
|
||||
map $request_uri $request_uri_path {
|
||||
"~^(?P<path>[^?]*)(\?.*)?$" $path;
|
||||
}
|
||||
|
||||
init_by_lua_block {
|
||||
cjson = require("cjson")
|
||||
-- gumbo = require("gumbo")
|
||||
}
|
||||
|
||||
server {
|
||||
|
@ -107,6 +110,7 @@ http {
|
|||
location /_meta_tags_html {
|
||||
internal;
|
||||
root /var/www;
|
||||
set $external_host_url "${scheme}://${http_host}";
|
||||
content_by_lua_file /etc/nginx/metatags.lua;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue