GithubHelp home page GithubHelp logo

isabella232 / grunt-fizzy-docs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from metafizzy/grunt-fizzy-docs

0.0 0.0 0.0 157 KB

Grunt tasks for Masonry, Isotope, and Packery docs

JavaScript 100.00%

grunt-fizzy-docs's Introduction

grunt-fizzy-docs

Grunt tasks for Masonry, Isotope, and Packery docs.

View documentation sources to see this in action.

int-bower

Integrates bower sources.

  • Adds .js and .css (taken from main in bower.json) files to concat task
  • Adds main files to copy task
  • Saves .js and .css files to JSON with dataDir option
grunt.initConfig({
  // global settings
  dataDir: '_tasks/data'
});

template

Generates site HTML with Handlebars templating.

  grunt.initConfig({
  template: {
    docs: {
      files: {
        // dest: src
        'build/': '_content/**/*.*'
      },
      options: {
        // load all templates from files
        templates: '_templates/*.mustache',
        // default template used
        defaultTemplate: 'page',
        // any other partials you want to hard code
        partialFiles: {
          'submitting-issues': 'bower_components/masonry/CONTRIBUTING.mdown'
        }
      }
    }
  }
});

Source files can contain JSON front matter, sort of like Jekyll's YAML front matter.

---
{
  "title": "FAQ",
  "nav": [
    "Overlapping",
    "Browser support",
    "Difference between Isotope and Masonry",
    "First item breaks grid"
  ]
}
---

Templating variables

JSON front matter is then passed in with the page variable for templating.

<h1>{{page.title}}</h1>
<ul class="nav">
  {{#each page.nav}}
    <li><a href="#{{slug this}}">{{this}}</a></li>
  {{/each}}
</ul>

Other variables:

  • basename - the name of the file. i.e. "index" for "content/index.html"
  • ref="{{root_path}}layout-modes/masonry - --dev command flag, for grunt default --dev
  • site
    • site.js - all .js files
    • site.css - all .css files

Here's how I use those variables. See desandro/masonry-docs/_templates/page.mustache

</head>
  {{#if is_dev}}
    <!-- DEV MODE - including each .css file -->
    {{#each site.css}}
      <link rel="stylesheet" href="{{this}}" />
    {{/each}}
  {{else}}
    {{! in production, just include concat CSS }}
    <link rel="stylesheet" href="css/masonry-docs.css" />
  {{/if}}
</head>

{{! unique page name for CSS, data-page to trigger JS }}
<body class="{{basename}}-page" data-page="{{basename}}"> 

grunt-fizzy-docs's People

Contributors

desandro avatar

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.