Merge pull request #1 from indirect/issue/461
Handle posts as well as pages. maybe.
This commit is contained in:
commit
95eda2f953
|
@ -66,12 +66,12 @@ module Jekyll
|
|||
|
||||
def build_absolute_path
|
||||
return raw_path unless raw_path.is_a?(String) && absolute_url?(raw_path) == false
|
||||
return filters.absolute_url(raw_path) if raw_path.start_with?("/")
|
||||
|
||||
if !raw_path.start_with?("/")
|
||||
return filters.absolute_url File.join(File.dirname(context.registers[:page]["url"]), raw_path)
|
||||
end
|
||||
page_dir = @page["url"]
|
||||
page_dir = File.dirname(page_dir) unless page_dir.end_with?("/")
|
||||
|
||||
filters.absolute_url raw_path
|
||||
filters.absolute_url File.join(page_dir, raw_path)
|
||||
end
|
||||
|
||||
def filters
|
||||
|
|
|
@ -14,6 +14,15 @@ RSpec.describe Jekyll::SeoTag::ImageDrop do
|
|||
Jekyll.logger.log_level = :error
|
||||
end
|
||||
|
||||
context "with a post object" do
|
||||
let(:image) { "image.png" }
|
||||
let(:page) { make_post(page_meta) }
|
||||
|
||||
it "returns the image url relative to the post directory" do
|
||||
expect(subject["path"]).to eql("/2022/07/26/image.png")
|
||||
end
|
||||
end
|
||||
|
||||
context "with image as a relative path" do
|
||||
let(:image) { "image.png" }
|
||||
|
||||
|
|
Loading…
Reference in New Issue