From ea8de413709d7695a971d46578ddc2b4a22f37e8 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Sat, 4 May 2024 19:51:33 +0200 Subject: [PATCH] [permalink] Ensure that the permalink is correctly set #199 It ensures that the permalink_lang attribute is set correctly and can be used when a permalink attribute is set at the site level. It is, indeed, not enough to check if the permalink is undefined. The permalink might be set to empty. Moreover, we should check that the page has a lang attribute isn't empty as well. --- lib/jekyll/polyglot/patches/jekyll/site.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/polyglot/patches/jekyll/site.rb b/lib/jekyll/polyglot/patches/jekyll/site.rb index a84bb3e00..250596bff 100644 --- a/lib/jekyll/polyglot/patches/jekyll/site.rb +++ b/lib/jekyll/polyglot/patches/jekyll/site.rb @@ -138,7 +138,7 @@ def coordinate_documents(docs) lang_exclusive = doc.data['lang-exclusive'] || [] url = doc.url.gsub(regex, '/') page_id = doc.data['page_id'] || url - doc.data['permalink'] = url unless defined?(doc.data['permalink']) + doc.data['permalink'] = url if doc.data['permalink'].to_s.empty? && !doc.data['lang'].to_s.empty? # skip entirely if nothing to check next if @file_langs.nil? @@ -185,7 +185,7 @@ def assignPageLanguagePermalinks(doc, docs) end end - # performs any necesarry operations on the documents before rendering them + # performs any necessary operations on the documents before rendering them def process_documents(docs) # return if @active_lang == @default_lang