Git Product home page Git Product logo

forematter's Introduction

Forematter

Forematter is the frontmatter-aware friend for your static site.

Install Forematter

Add this line to your application's Gemfile:

gem 'forematter'

And then execute:

$ bundle

Or install it yourself, if that's what you're into:

$ gem install forematter

If you're not running a Ruby version manager, you might need to use sudo gem install forematter instead. But try it without the sudo first.

Use Forematter for Good

Forematter makes it easy to add tags I forgot:

$ find . -name "*twitter*.md" | xargs fore add tags twitter

And find all of my dumb:

$ find . -name "*twitter*.md" | xargs fore list tags | grep -i tw

Twitpocalypse
Twitter
twitter

... whoops. Let's fix that:

$ fore merge tags Twitter twitter *.md
$ find . -name "*twitter*.md" | xargs fore list tags | grep -i tw

Twitpocalypse
Twitter

Much better!

Use Forematter for Awesome

Forematter lets me automatically categorize all my blog posts, based on the tags I use:

# Grab the 10 most common tags from my blog
for c in $(fore count tags *.md | tail -10 | sort -r | awk '{print($2)}'); do
  # Set the category on each article with one of these tags
  fore search -l tags "$c" *.md | xargs fore set category "$c"
end

# Format categories as title case
fore cleanup category --titlecase *.md

# Automatically classify all articles which don't already have a category
fore classify category *.md

It does a lot more, too:

fore fields                        content/*.md
fore rename   categories tags      content/*.md

fore add      tags   foo bar       content/*.md
fore remove   tags   bacon         content/*.md
fore merge    tags   foo Foo       content/*.md
fore count    tags                 content/*.md
fore search   tags                 content/*.md
fore list     tags                 content/*.md

fore set      title  'title!'      content/foo.md
fore unset    title                content/bar.md
fore list     title                content/*.md

fore touch    updated_at           content/baz.md

fore cleanup  title --titlecase    content/*.md
fore cleanup  name  --capitalize   content/*.md
fore cleanup  tags  --downcase     content/*.md
fore cleanup  slug  --url          content/*.md
fore cleanup  title --trim         content/*.md
fore cleanup  tags  --sort         content/*.md

fore classify category             content/*.md
fore classify category --override  content/*.md

fore --help

Use it in your shell

Forematter tries to be a good *nix citizen. It plays nice with find and grep and awk. Mix and match with all your favorite command line tools!

Use it everywhere

Forematter isn't tied to any particular static site generator. If your files have YAML frontmatter, Forematter is the tool for you.

If you're looking for a great static site generator, go check out this list — 210 of 'em and counting!

If Forematter doesn't work with your favorite, let us know.

Buyer beware

Forematter works by editing your site's content files. There is a nonzero chance that you'll do something you regret, and Forematter can't help you ⌘Z.

If you're not keeping things under version control, this would be a good time to start!

forematter's People

Contributors

bobthecow avatar

Stargazers

Daniel Warner Smith avatar Denis Defreyne avatar Jan Vlnas avatar Paulo Elias avatar Jérôme Foray avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

jnv

forematter's Issues

don't crash with stack trace for recoverable errors

Case 1:
when processing a list of files, rescue from File Not Found RuntimeError, print the error to standard error, and continue with the rest of the files in the list. Exit with non-zero status to indicate not all files were processed as requested.

Case 2:
When attempting to perform an operation that doesn't make sense, i.e. adding to an element that is not a set, print an error message to standard error and exit with non-zero status, but don't print a stack trace.

undefined method `downcase' for nil:NilClass (NoMethodError)

when querying a particular element that does not exist

$ find content/ -type f -name '*.md' | xargs fore list tags                                                                                                              
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/forematter-0.1.0/lib/forematter/commands/list.rb:13:in `each': undefined method `downcase' for nil:NilClass (NoMethodError)
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/forematter-0.1.0/lib/forematter/commands/list.rb:13:in `sort_by'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/forematter-0.1.0/lib/forematter/commands/list.rb:13:in `run'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/forematter-0.1.0/lib/forematter/command_runner.rb:6:in `call'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/cri-2.4.1/lib/cri/command_dsl.rb:185:in `block in runner'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/cri-2.4.1/lib/cri/command.rb:298:in `call'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/cri-2.4.1/lib/cri/command.rb:298:in `run_this'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/cri-2.4.1/lib/cri/command.rb:251:in `run'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/cri-2.4.1/lib/cri/command.rb:264:in `run'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/forematter-0.1.0/lib/forematter.rb:36:in `run'
        from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/forematter-0.1.0/bin/fore:10:in `<top (required)>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.