Last active
May 5, 2016 14:04
-
-
Save wtnabe/4e57c3fc01665b5d32ec621590e9c5fe to your computer and use it in GitHub Desktop.
Jekyll drafts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns whether the document is a draft. This is only the case if | |
# the document is in the 'posts' collection but in a different | |
# directory than '_posts'. | |
# | |
# Returns whether the document is a draft. | |
def draft? | |
data['draft'] ||= relative_path.index(collection.relative_directory).nil? && collection.label == "posts" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_で始まらない通常のディレクトリか、 _posts/ ディレクトリ以外に置かれているものはすべて draft 扱いになり、variable draft に true か false が入る。{% %} の中では TrueClass or FalseClass で、 {{ }} の中では "true" or "false" で返ってくる。
collection を定義して posts 以外に増やしたとしてもそれらの collection に対しては draft の機能を使えないように見えるけど、どうなんだろう?