Skip to content

Commit

Permalink
Quicker categories for documents without superdirs (#7987)
Browse files Browse the repository at this point in the history
Merge pull request 7987
  • Loading branch information
ashmaroli committed Mar 30, 2020
1 parent f7bff1c commit 6bc27f9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/jekyll/document.rb
Expand Up @@ -414,9 +414,13 @@ def respond_to_missing?(method, *)
#
# 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
Expand Down

0 comments on commit 6bc27f9

Please sign in to comment.