From 4f81011442495c6f62279fb74c97a00528c87df5 Mon Sep 17 00:00:00 2001 From: Seeker Date: Wed, 19 Aug 2020 10:16:18 -0700 Subject: [PATCH] Supress warning issued for redirect pages (#8347) Merge pull request 8347 --- features/permalinks.feature | 17 +++++++++++++++++ lib/jekyll/commands/doctor.rb | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/features/permalinks.feature b/features/permalinks.feature index 31c55105..e462627e 100644 --- a/features/permalinks.feature +++ b/features/permalinks.feature @@ -151,3 +151,20 @@ Feature: Fancy permalinks And the _site directory should exist And I should see "Conflict: The URL '" in the build output And I should see "amazing.html' is the destination for the following pages: awesome.md, cool.md" in the build output + + Scenario: Redirecting from an existing permalink + Given I have a configuration file with "plugins" set to "[jekyll-redirect-from]" + And I have a "deals.html" file with content: + """ + --- + permalink: /deals/ + redirect_from: + - /offers/ + --- + """ + And I have a "offers.html" page with permalink "/offers/" that contains "Hurry! Limited time only!" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should not see "Conflict: The URL '" in the build output + And I should not see "offers/index.html' is the destination for the following pages: offers.html, redirect.html" in the build output diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index d81eceff..ca830576 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -124,6 +124,8 @@ module Jekyll def collect_urls(urls, things, destination) things.each do |thing| + next if allow_used_permalink?(thing) + dest = thing.destination(destination) if urls[dest] urls[dest] << thing.path @@ -134,6 +136,10 @@ module Jekyll urls end + def allow_used_permalink?(item) + defined?(JekyllRedirectFrom) && item.is_a?(JekyllRedirectFrom::RedirectPage) + end + def case_insensitive_urls(things, destination) things.each_with_object({}) do |thing, memo| dest = thing.destination(destination)