From f544be414491570600ba8f7f9f4fe2a57762c550 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Wed, 1 May 2024 00:00:45 -0300 Subject: [PATCH] Fix / improve render of meta tags (stream.html.erb) --- nanoc/lib/mixin/opengraph.rb | 7 ++++--- nanoc/rules/stream.rules | 20 ++++++++++++-------- src/html/stream.html.erb | 20 ++++++++++---------- src/json/t.json | 8 ++++---- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/nanoc/lib/mixin/opengraph.rb b/nanoc/lib/mixin/opengraph.rb index 1b8b0ae6f..858b7b04e 100644 --- a/nanoc/lib/mixin/opengraph.rb +++ b/nanoc/lib/mixin/opengraph.rb @@ -8,10 +8,11 @@ module Mixin::OpenGraph def local_assigns(context) case context.filename when "stream.html.erb" + surah = context.surah {title: t(context.locale, "TheNobleQuran"), - description: t(context.locale, "meta.stream.description", surah_name: context.surah.name), - url: "https://al-quran.reflectslight.io/#{context.locale}/#{context.surah.slug}/", - image: "https://al-quran.reflectslight.io/images/opengraph/#{context.surah.id}.png"} + description: t(context.locale, "meta.stream.description", surah_name: surah.name), + url: "https://al-quran.reflectslight.io/#{context.locale}/#{surah.slug}/", + image: "https://al-quran.reflectslight.io/images/opengraph/#{surah.id}.png"} when "index.html.erb" {title: t(context.locale, "TheNobleQuran"), description: t(context.locale, "meta.index.description"), diff --git a/nanoc/rules/stream.rules b/nanoc/rules/stream.rules index 450a91184..770a8e268 100644 --- a/nanoc/rules/stream.rules +++ b/nanoc/rules/stream.rules @@ -12,25 +12,29 @@ compile "/json/*/*/surah.json" do end end -Ryo.each(name_by_id) do |id, transliterated_name| - writer = ->(locale, identifier:) do +Ryo.each(name_by_id) do |id, slug| + write_file = ->(locale, pathname:) do name = tdata[locale].surahs.names[id.to_i - 1] context = Ryo.from( filename: "stream.html.erb", locale:, locales:, - surah: {id:, name:, transliterated_name:} + surah: {id:, name:, slug:} ) - filter(:erb, locals: {context:}) + locals = { + locale: context.locale, locales: context.locales, + surah: context.surah, context: + } + filter(:erb, locals:) filter(:tidy) - write "/#{locale}/#{identifier}/index.html" + write "/#{locale}/#{pathname}/index.html" end locales.each do |locale| - compile "/html/stream.html.erb", rep: "/#{locale}/#{transliterated_name}/index.html" do - instance_exec(locale, identifier: transliterated_name, &writer) + compile "/html/stream.html.erb", rep: "/#{locale}/#{slug}/index.html" do + instance_exec(locale, pathname: slug, &write_file) end compile "/html/stream.html.erb", rep: "/#{locale}/#{id}/index.html" do - instance_exec(locale, identifier: id, &writer) + instance_exec(locale, pathname: id, &write_file) end end end diff --git a/src/html/stream.html.erb b/src/html/stream.html.erb index d150651fa..5170446d9 100644 --- a/src/html/stream.html.erb +++ b/src/html/stream.html.erb @@ -1,23 +1,23 @@ - +
-