Quicker categories for documents without superdirs (#7987)

Merge pull request 7987
This commit is contained in:
Ashwin Maroli 2020-03-30 20:06:37 +05:30 committed by GitHub
parent f7bff1c5c4
commit 6bc27f9fdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -414,9 +414,13 @@ module Jekyll
#
# Returns nothing.
def categories_from_path(special_dir)
superdirs = relative_path.sub(Document.superdirs_regex(special_dir), "")
superdirs = superdirs.split(File::SEPARATOR)
superdirs.reject! { |c| c.empty? || c == special_dir || c == basename }
if relative_path.start_with?(special_dir)
superdirs = []
else
superdirs = relative_path.sub(Document.superdirs_regex(special_dir), "")
superdirs = superdirs.split(File::SEPARATOR)
superdirs.reject! { |c| c.empty? || c == special_dir || c == basename }
end
merge_data!({ "categories" => superdirs }, :source => "file path")
end