Socket
Book a DemoInstallSign in
Socket

middleman-blog-drafts

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

middleman-blog-drafts

0.3.3
bundlerRubygems
Version published
Maintainers
2
Created
Source

middleman-blog-drafts

Build Status

middleman-blog-drafts is an addon for middleman-blog that simplifies draft posts creation and publishing.

Install

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

Then add middleman-blog-drafts to your Gemfile and activate the extension in your config.rb:

activate :drafts

Generating drafts

middleman draft 'My awesome new blog post'

Publishing drafts

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.

Configuration options

build: when true, the drafts will be available unconditionally. If not given, the drafts will be available in middleman's development mode and unavailable in middleman build.

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.

Frontmatter options

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 build to true for your entire blog, you may still withhold single drafts from being built by setting build: false in the frontmatter.

Learn More

See the blog extension guide for detailed information on configuring and using the blog extension.

Credits

Most of the code was based on the middleman-blog gem itself, so many thanks to everyone that helped out with it.

Contributing

  • 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

FAQs

Package last updated on 03 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.