middleman-blog-drafts is an addon for middleman-blog that simplifies draft posts creation and publishing.
If you're just getting started, install the required gems and generate a new blog project:
gem install middleman middleman-blog-drafts middleman init MY_BLOG_PROJECT --template=blog
middleman-blog-drafts to your
Gemfile and activate the extension in your
middleman draft 'My awesome new blog post'
middleman publish source/drafts/my-awesome-new-blog-post.markdown
Listing drafts on a page
<% if drafts.any? %> <ul> <% drafts.each do |draft| %> <li><%= link_to draft.title, draft.path %></li> <% end %> </ul> <% end %>
As drafts won't be be available in the generated page by default, checking whether there are any is enough to decide whether to render the listing or not.
true, the drafts will be available unconditionally. If not
given, the drafts will be available in middleman's development mode and
This allows you to control the behaviour, for example if you have a preview instance of your blog. One way to do so would be to set it based on an environment variable:
activate :drafts do |drafts| drafts.build = true if ENV["SHOW_DRAFTS"] end
This activates drafts in any environment where
SHOW_DRAFTS is given and uses
the default otherwise.
build can be overriden on a per-draft basis. For example if you want to make
a draft available to a small audience for proofreading, you may force the build
of that one draft with the following frontmatter:
--- title: "Example blog post" build: true ---
Likewise if you configure
true for your entire blog, you may still
withhold single drafts from being built by setting
build: false in the
See the blog extension guide for detailed information on configuring and using the blog extension.
Most of the code was based on the middleman-blog gem itself, so many thanks to everyone that helped out with it.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request