Replace opengraph.rb with _opengraph.html.erb
This commit is contained in:
parent
8bd369f332
commit
257b057d4b
8 changed files with 28 additions and 45 deletions
|
@ -10,7 +10,6 @@ module Utils
|
|||
require_relative "utils/t"
|
||||
require_relative "utils/inline"
|
||||
require_relative "utils/erb"
|
||||
require_relative "utils/opengraph"
|
||||
|
||||
##
|
||||
# Generic error
|
||||
|
@ -89,7 +88,6 @@ module Utils
|
|||
include T
|
||||
include Inline
|
||||
include ERB
|
||||
include OpenGraph
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Utils::OpenGraph
|
||||
def opengraph(context)
|
||||
erb "_opengraph.html.erb", local_assigns(context)
|
||||
end
|
||||
|
||||
def local_assigns(context)
|
||||
case context.filename
|
||||
when "surah-stream.html.erb"
|
||||
surah = context.surah
|
||||
{title: t(context.locale, "TheNobleQuran"),
|
||||
description: surah.name,
|
||||
url: "#{base_url}/#{context.locale}/#{surah.slug}/",
|
||||
image: "#{base_url}/images/og/#{surah.id}.png?v=#{commit}"}
|
||||
when "redirect.html.erb", "surah-index.html.erb"
|
||||
{title: t(context.locale, "TheNobleQuran"),
|
||||
description: t(context.locale, "meta.index.description"),
|
||||
url: "#{base_url}/#{context.locale}/",
|
||||
image: "#{base_url}/images/og/0.png"}
|
||||
when "random.html.erb"
|
||||
{title: t(context.locale, "TheNobleQuran"),
|
||||
description: t(context.locale, "meta.random.description"),
|
||||
url: "#{base_url}/#{context.locale}/random/",
|
||||
image: "#{base_url}/images/og/0.png"}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,7 +6,7 @@
|
|||
# to the surah index for a given locale (eg / -> /en/)
|
||||
|
||||
compile "/html/main/redirect.html.erb" do
|
||||
filter(:erb, locals: {locales:})
|
||||
filter(:erb, locals: {context: Ryo(locale: "en"), locales:})
|
||||
filter(:tidy, exe: tidy)
|
||||
write("/index.html")
|
||||
end
|
||||
|
|
|
@ -1,6 +1,22 @@
|
|||
<meta property="og:type" content="article"/>
|
||||
<meta property="og:title" content="<%= title %>"/>
|
||||
<meta property="og:description" content="<%= description %>"/>
|
||||
<meta property="og:url" content="<%= url %>"/>
|
||||
<meta property="og:image" content="<%= image %>"/>
|
||||
<meta property="og:image:type" content="image/png"/>
|
||||
<% if file == "surah-index.html.erb" || file == "redirect.html.erb" %>
|
||||
<meta property="og:type" content="article"/>
|
||||
<meta property="og:title" content="<%= t(context.locale, 'TheNobleQuran') %>"/>
|
||||
<meta property="og:description" content="<%= t(context.locale, 'meta.index.description') %>"/>
|
||||
<meta property="og:url" content="<%= base_url %>/<%= context.locale %>/"/>
|
||||
<meta property="og:image" content="<%= base_url %>/images/og/0.png?v=<%= commit %>"/>
|
||||
<meta property="og:image:type" content="image/png"/>
|
||||
<% elsif file == "surah-stream.html.erb" %>
|
||||
<meta property="og:type" content="article"/>
|
||||
<meta property="og:title" content="<%= t(context.locale, 'TheNobleQuran') %>"/>
|
||||
<meta property="og:description" content="<%= context.surah.name %>"/>
|
||||
<meta property="og:url" content="<%= base_url %>/<%= context.locale %>/<%= context.surah.slug %>/"/>
|
||||
<meta property="og:image" content="<%= base_url %>/images/og/<%= context.surah.id %>.png?v=<%= commit %>"/>
|
||||
<meta property="og:image:type" content="image/png"/>
|
||||
<% elsif file == "random.html.erb" %>
|
||||
<meta property="og:type" content="article"/>
|
||||
<meta property="og:title" content="<%= t(context.locale, 'TheNobleQuran') %>"/>
|
||||
<meta property="og:description" content="<%= t(context.locale, 'meta.random.description') %>"/>
|
||||
<meta property="og:url" content="<%= base_url %>/<%= context.locale %>/random/"/>
|
||||
<meta property="og:image" content="<%= base_url %>/images/og/0.png?v=<%= commit %>"/>
|
||||
<meta property="og:image:type" content="image/png"/>
|
||||
<% end %>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<title><%= t(locale, "TheNobleQuran") %></title>
|
||||
<meta name="description" content="<%= t(locale, 'meta.random.description') %>">
|
||||
<%= erb("_version.html.erb") %>
|
||||
<%= opengraph(context) %>
|
||||
<%= erb("_opengraph.html.erb", {file: "random.html.erb", context:}) %>
|
||||
<link
|
||||
rel="canonical"
|
||||
href="<%= base_url %>/<%= locale %>/random/"
|
||||
|
|
|
@ -4,11 +4,8 @@
|
|||
<title><%= t("en", "TheNobleQuran") %></title>
|
||||
<meta name="description" content="<%= t('en', 'meta.index.description') %>">
|
||||
<%= erb("_version.html.erb") %>
|
||||
<%= opengraph(Ryo(filename: "redirect.html.erb", locale: "en")) %>
|
||||
<link
|
||||
rel="canonical"
|
||||
href="<%= base_url %>/en/"
|
||||
/>
|
||||
<%= erb("_opengraph.html.erb", {page: "redirect.html.erb", context:}) %>
|
||||
<link rel="canonical" href="<%= base_url %>/en/" />
|
||||
<% locales.each do |locale| %>
|
||||
<link
|
||||
rel="alternate"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="description" content="<%= t(locale, 'meta.index.description') %>">
|
||||
<%= erb("_version.html.erb") %>
|
||||
<%= opengraph(context) %>
|
||||
<%= erb("_opengraph.html.erb", {file: "surah-index.html.erb", context:}) %>
|
||||
<link
|
||||
rel="canonical"
|
||||
href="<%= base_url %>/<%= locale %>/"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="description" content="<%= t(locale, 'meta.stream.description') %>">
|
||||
<%= erb("_version.html.erb") %>
|
||||
<%= opengraph(context) %>
|
||||
<%= erb("_opengraph.html.erb", {file: "stream-stream.html.erb", context:}) %>
|
||||
<link
|
||||
rel="canonical"
|
||||
href="<%= base_url %>/<%= locale %>/<%= surah.slug %>/"
|
||||
|
|
Loading…
Reference in a new issue