forked from ti-nuage/site
Ajout de la carte de Vieux-Marché.
This commit is contained in:
@@ -10,7 +10,7 @@ module.exports = {
|
||||
paths: {
|
||||
projectRoot,
|
||||
/* Nodes */
|
||||
nodeModules: join(projectRoot, 'node_modules'),
|
||||
leaflet: join(projectRoot, 'node_modules', 'leaflet', 'dist'),
|
||||
/* Metalsmith */
|
||||
metalsmithSource: 'content',
|
||||
metalsmithDestination: distribution,
|
||||
|
||||
47
scripts/metalsmith-copy.js
Normal file
47
scripts/metalsmith-copy.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const debug = require('debug')('metalsmith-copy')
|
||||
const fs = require('fs')
|
||||
const mode = require('stat-mode')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = plugin
|
||||
|
||||
function plugin (options) {
|
||||
options = Object.assign({ destination: '.' }, options)
|
||||
|
||||
return function (files, metalsmith, done) {
|
||||
const dest = options.destination
|
||||
const items = options.files.length
|
||||
const promises = []
|
||||
|
||||
const addTask = function (promise) {
|
||||
promises.push(promise)
|
||||
if (items === promises.length) {
|
||||
debug('Waiting for ' + items + 'copy operations.')
|
||||
Promise.all(promises)
|
||||
.then((data) => {
|
||||
done()
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
options.files.forEach((filename) => {
|
||||
addTask(new Promise(function (resolve, reject) {
|
||||
fs.stat(filename, function (err, stats) {
|
||||
if (err) return reject(err)
|
||||
fs.readFile(filename, function (err, buffer) {
|
||||
if (err) return reject(err)
|
||||
const file = {
|
||||
contents: buffer,
|
||||
mode: mode(stats).toOctal()
|
||||
}
|
||||
files[path.join(dest, path.basename(filename))] = file
|
||||
resolve({})
|
||||
})
|
||||
})
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ const cleanCSS = require('metalsmith-clean-css')
|
||||
const chatons = require('./metalsmith-tinuage-chatons')
|
||||
const config = require('./config.js')
|
||||
const collections = require('@metalsmith/collections')
|
||||
const copy = require('./metalsmith-copy')
|
||||
const excerpts = require('@metalsmith/excerpts')
|
||||
const groff = require('metalsmith-groff')
|
||||
const layouts = require('@metalsmith/layouts')
|
||||
@@ -72,6 +73,25 @@ module.exports = new Metalsmith(config.paths.projectRoot)
|
||||
source: './assets/' + (process.env.NODE_ENV || 'dev'),
|
||||
destination: './'
|
||||
}))
|
||||
.use(copy({
|
||||
files: [join(config.paths.leaflet, 'leaflet.css')],
|
||||
destination: './css'
|
||||
}))
|
||||
.use(copy({
|
||||
files: [
|
||||
join(config.paths.leaflet, 'images', 'marker-icon.png'),
|
||||
join(config.paths.leaflet, 'images', 'marker-icon-2x.png'),
|
||||
join(config.paths.leaflet, 'images', 'marker-shadow.png')
|
||||
],
|
||||
destination: './css/images'
|
||||
}))
|
||||
.use(copy({
|
||||
files: [
|
||||
join(config.paths.leaflet, 'leaflet.js'),
|
||||
join(config.paths.leaflet, 'leaflet.js.map')
|
||||
],
|
||||
destination: './js'
|
||||
}))
|
||||
.use(groff({
|
||||
macroPackages: ['mm', 'tinuage'],
|
||||
macroPaths: [join(config.paths.projectRoot, 'scripts/tmac')],
|
||||
|
||||
Reference in New Issue
Block a user