Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to set collections_dir to put all collections under one subdirectory #6331

Merged
merged 3 commits into from
Sep 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/_docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -602,12 +602,13 @@ file or on the command-line.

```yaml
# Where things are
source: .
destination: ./_site
plugins_dir: _plugins
layouts_dir: _layouts
data_dir: _data
includes_dir: _includes
source: .
destination: ./_site
collections_dir: .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be "" instead of a .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashmaroli Isn't it the current directory? (ie: same as source?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was pointing at a discrepancy in lib/jekyll/configuration.rb above and the documentation here..

In lib/jekyll/configuration.rb above, its {"source" => Dir.pwd, "collections_dir" => ""} but here its source: . and collections_dir: .

plugins_dir: _plugins
layouts_dir: _layouts
data_dir: _data
includes_dir: _includes
collections:
posts:
output: true
Expand Down
4 changes: 2 additions & 2 deletions lib/jekyll/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ def filtered_entries
# Returns a String containing the directory name where the collection
# is stored on the filesystem.
def relative_directory
@relative_directory ||= "_#{label}"
@relative_directory ||= Pathname.new(directory).relative_path_from(Pathname.new(site.source)).to_s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a breaking change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a breaking change because the functionality is now in the directory method below.

Copy link
Member Author

@parkr parkr Aug 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be a breaking change if plugins did instance_variable_set(:@relative_directory, "blah") and hoped it would affect directory. It reverses their role for sure, but instance variable manipulation like that is 💯 % not supported.

end

# The full path to the directory containing the collection.
#
# Returns a String containing th directory name where the collection
# is stored on the filesystem.
def directory
@directory ||= site.in_source_dir(relative_directory)
@directory ||= site.in_source_dir(File.join(site.config["collections_dir"], "_#{label}"))
end

# The full path to the directory containing the collection, with
Expand Down
1 change: 1 addition & 0 deletions lib/jekyll/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Configuration < Hash
# Where things are
"source" => Dir.pwd,
"destination" => File.join(Dir.pwd, "_site"),
"collections_dir" => "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in docs/_docs/configuration.md collections_dir has a value of . (interpreted as current location) but its empty here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an empty string here is fine. If site.config["collections_dir"] is empty, then File.join will do the right things with the paths.

"plugins_dir" => "_plugins",
"layouts_dir" => "_layouts",
"data_dir" => "_data",
Expand Down