Esempio n. 1
0
gulp.task('build-event-templates', () => {
  return gulp.src(paths.events.src)
    .pipe($.frontMatter().on('data', file => {
      Object.assign(file, file.frontMatter)
      delete file.frontMatter
    }))
    .pipe(
      gulpsmith()
        .metadata({
          site: {
            url: CONFIG.root_url,
            title: 'DC/OS Events',
            image_url: './assets/images/rss-logo.png'
          }
        })
        .use(addTimestampToMarkdownFiles)
        .use(markdown({
          smartypants: true,
          gfm: true,
          tables: true
        }))
        .use(jade({
          locals: { cssTimestamp },
          pretty: true
        }))
        .use(permalinks({
          pattern: ':title',
          date: 'YYYY',
          linksets: [{
            match: { collection: 'events' },
            pattern: 'events/:date/:title'
          }]
        }))
        .use(collections({
          events: {
            pattern: '*.md',
            sortBy: 'date',
            reverse: true
          }
        }))
        .use(addPropertiesToCollectionItems('events', eventpost => {
          return Object.assign(eventpost, {
            formattedDate: moment(eventpost.date).format('MMMM DD')
          })
        }))
        .use(writemetadata({
          collections: {
            events: {
              output: {
                path: 'events/events.json',
                asObject: true
              },
              ignorekeys: ['contents', 'next', 'previous', 'stats', 'mode', 'lunr']
            }
          }
        }))
        .use(tags({
          handle: 'category',
          path: 'events/category/:tag.html',
          layout: '../layouts/event-category.jade',
          sortBy: 'date',
          reverse: true
        }))
        .use(mlunr({
          indexPath: 'events/search-index.json',
          fields: {
            contents: 2,
            title: 10,
            category: 5
          }
        }))
        .use(define({
          moment,
          rootUrl: CONFIG.root_url
        }))
        .use(feed({ collection: 'events' }))
        .use(layouts({
          pattern: '**/*.html',
          engine: 'jade',
          directory: path.join('layouts')
        }))
        .use(reloadInMetalsmithPipeline)
  )
    .pipe(gulp.dest(paths.build))
})
Esempio n. 2
0
     pattern: '*.md',
     sortBy: 'date',
     reverse: true
   }
 }))
 .use(addPropertiesToCollectionItems('posts', post => {
   return Object.assign(post, {
     formattedDate: moment(post.date).format('MMMM DD')
   })
 }))
 .use(writemetadata({
   collections: {
     posts: {
       output: {
         path: 'blog/posts.json',
         asObject: true
       },
       ignorekeys: ['contents', 'next', 'previous', 'stats', 'mode', 'lunr']
     }
   }
 }))
 .use(tags({
   handle: 'category',
   path:'blog/category/:tag.html',
   layout:'../layouts/blog-category.jade',
   sortBy: 'date',
   reverse: true
 }))
 .use(mlunr({
   indexPath: 'blog/search-index.json',
   fields: {
Esempio n. 3
0
// TODO - reorganize these tasks
function build(production){
  return Metalsmith(__dirname)
    .clean(false)
    .metadata(config)
    .use(function(files, metadata, callback){
      if(production){
        drafts()(files, metadata, callback);
      } else {
        callback();
      }
    })
    .use(templates({
      engine: 'swig',
      inPlace: true,
      pattern: '**/*.md'
    }))
    .use(collections({
      posts: {
        pattern: 'posts/*.md',
        sortBy: 'date',
        reverse: true
      },
      pages: {
        pattern: '*.md',
        sortBy: 'priority'
      }
    }))
    .use(metallic())
    .use(markdown())
    .use(permalinks({
        pattern: 'blog/:title',
        relative: false
    }))
    .use(feed({collection: 'posts'}))
    .use(excerpts({
      pruneLength: 160
    }))
    .use(pagination({
      'collections.posts': {
        perPage: 10,
        template: 'collection.html',
        first: 'blog/index.html',
        path: 'blog/:num/index.html'
      }
    }))
    .use(tags({
      handle: 'tags',
      template:'tags.html',
      path:'tags/:tag/index.html',
      pathPage: 'tags/:tag/:num/index.html',
      perPage: 10,
      sortBy: 'data',
      reverse: true
    }))
    // render template data in markdown files
    .use(templates({
      engine: 'swig'
    }))
    .use(writemetadata({
      bufferencoding: 'utf8',
      collections: {
        posts: {
          output: {
            asObject: true,
            path: 'blog/index.json',
            metadata: {
              "type": "list"
            }
          },
          ignorekeys: ['history', 'stats', 'next', 'template', 'previous', 'collection', 'mode'],
        }
      }
    }))
    .use(function(files, metadata, callback){
      if(production){
        htmlMinifier()(files, metadata, callback);
      } else {
        callback();
      }
    })
    .destination('build/')
    .build(function(err,files){
      if (err){ console.log(err); }
      livereload();
    });
}
Esempio n. 4
0
    from: '*.scss',
    to: '*.css',
    map: devBuild ? {inline: false} : false,
    plugins: {
      'autoprefixer': {browsers: ['> 0.5%', 'Explorer >= 10']}
    }
  }))
  .use(webpack(webpackConfig(config)))
  .use(assets({
    source: './src/assets', // relative to the working directory
    destination: './assets' // relative to the build directory
  }))

if (debugMode) {
  ms.use(writemetadata({
    pattern: ['**/*.html'],
    bufferencoding: 'utf8'
  }))
}

if (devBuild) {
  ms.use(browserSync({
    server: config.dest,
    files: [config.src + '**/*.*', 'layouts/*.*', 'partials/**/*.*'],
    open: false,
    notify: false
  }))
}

ms.use(debug({
  files: false,
  match: '**/*.md'