Memoize destination of pages, documents and staticfiles (#8458)

Merge pull request 8458
This commit is contained in:
Ashwin Maroli 2020-11-06 18:35:02 +05:30 committed by GitHub
parent 56d59a1782
commit 920c6f4ddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

View File

@ -257,13 +257,16 @@ module Jekyll
#
# Returns the full path to the output file of this document.
def destination(base_directory)
path = site.in_dest_dir(base_directory, URL.unescape_path(url))
if url.end_with? "/"
path = File.join(path, "index.html")
else
path << output_ext unless path.end_with? output_ext
@destination ||= {}
@destination[base_directory] ||= begin
path = site.in_dest_dir(base_directory, URL.unescape_path(url))
if url.end_with? "/"
path = File.join(path, "index.html")
else
path << output_ext unless path.end_with? output_ext
end
path
end
path
end
# Write the generated Document file to the destination directory.

View File

@ -158,10 +158,13 @@ module Jekyll
#
# Returns the destination file path String.
def destination(dest)
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index") if url.end_with?("/")
path << output_ext unless path.end_with? output_ext
path
@destination ||= {}
@destination[dest] ||= begin
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index") if url.end_with?("/")
path << output_ext unless path.end_with? output_ext
path
end
end
# Returns the object as a debug String.

View File

@ -55,7 +55,8 @@ module Jekyll
#
# Returns destination file path.
def destination(dest)
@site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
@destination ||= {}
@destination[dest] ||= @site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
end
def destination_rel_dir