Got rid of moment as a direct dependency.
This commit is contained in:
parent
bc40b6a47d
commit
0aa8d9171a
8 changed files with 14 additions and 16 deletions
|
|
@ -1,5 +1,4 @@
|
|||
const debug = require('debug')('metalsmith-gemini:comments')
|
||||
const moment = require('moment')
|
||||
|
||||
module.exports = plugins
|
||||
|
||||
|
|
@ -35,7 +34,7 @@ function plugins (helpers) {
|
|||
body += '=> /' + entry.filename + ' ' + entry.book.title + ', ' + entry.book.author
|
||||
|
||||
if (index === entry.comment.medium) {
|
||||
body += ' (' + entry.comment.date.year() + ')\n'
|
||||
body += ' (' + entry.comment.date.getFullYear() + ')\n'
|
||||
} else {
|
||||
body += ' (sur ' + entry.comment.medium + ')\n'
|
||||
body += entry.comment.excerpt
|
||||
|
|
@ -74,7 +73,7 @@ function plugins (helpers) {
|
|||
const data = files[filename]
|
||||
|
||||
if (data.comment !== undefined) {
|
||||
data.comment.date = moment(data.comment.date)
|
||||
data.comment.date = new Date(data.comment.date)
|
||||
data.comment.excerpt = buildExcerpt(data.contents.toString())
|
||||
data.comment.size = data.contents.length
|
||||
data.layout = 'gemini-comment.njk'
|
||||
|
|
@ -106,7 +105,7 @@ function plugins (helpers) {
|
|||
})
|
||||
|
||||
body += '\n## Par année\n\n'
|
||||
Object.keys(sortedComments(metalsmith, (c) => c.date.year())).forEach((year) => {
|
||||
Object.keys(sortedComments(metalsmith, (c) => c.date.getFullYear())).forEach((year) => {
|
||||
body += '=> /chroniques/' + year + ' ' + year + '\n'
|
||||
})
|
||||
|
||||
|
|
@ -124,7 +123,7 @@ function plugins (helpers) {
|
|||
},
|
||||
|
||||
yearIndexes: function (files, metalsmith, done) {
|
||||
Object.entries(sortedComments(metalsmith, (c) => c.date.year())).forEach(([year, comments]) => {
|
||||
Object.entries(sortedComments(metalsmith, (c) => c.date.getFullYear())).forEach(([year, comments]) => {
|
||||
helpers.createFile(files, helpers.filepath('index', ['chroniques', year]), createCommentsIndex(year, comments))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ const comments = require('./metalsmith-gemini-comments.js')
|
|||
const config = require('./config.js')
|
||||
const Metalsmith = require('metalsmith')
|
||||
const layouts = require('@metalsmith/layouts')
|
||||
const moment = require('moment')
|
||||
const path = require('path')
|
||||
const readings = require('./metalsmith-gemini-readings.js')
|
||||
const slug = require('slug')
|
||||
|
|
@ -10,8 +9,6 @@ const statistics = require('./metalsmith-statistics-plugin')
|
|||
|
||||
const __PROD__ = process.env.NODE_ENV === 'production'
|
||||
|
||||
moment.locale('fr')
|
||||
|
||||
function filepath (filename, segments) {
|
||||
const name = slug(filename, { mode: 'rfc3986' }) + '.gemini'
|
||||
return path.join.apply(null, (segments || ['./']).concat([name]))
|
||||
|
|
@ -42,6 +39,10 @@ const readingsGenerator = readings(helpers)
|
|||
module.exports = new Metalsmith(config.paths.projectRoot)
|
||||
.clean(__PROD__)
|
||||
.metadata({
|
||||
date_format: function (lang, date) {
|
||||
const options = { dateStyle: 'long' }
|
||||
return Intl.DateTimeFormat(lang, options).format(date)
|
||||
},
|
||||
filepath
|
||||
})
|
||||
.source(config.paths.geminiSource)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ const groff = require('metalsmith-groff')
|
|||
const layouts = require('@metalsmith/layouts')
|
||||
const Metalsmith = require('metalsmith')
|
||||
const markdown = require('@metalsmith/markdown')
|
||||
const moment = require('moment')
|
||||
const rename = require('metalsmith-rename')
|
||||
const permalinks = require('@metalsmith/permalinks')
|
||||
const sitemap = require('metalsmith-sitemap')
|
||||
|
|
@ -17,7 +16,10 @@ const __PROD__ = process.env.NODE_ENV === 'production'
|
|||
module.exports = new Metalsmith(config.paths.projectRoot)
|
||||
.clean(__PROD__)
|
||||
.metadata({
|
||||
moment,
|
||||
date_format: function (lang, date) {
|
||||
const options = { dateStyle: 'long' }
|
||||
return Intl.DateTimeFormat(lang, options).format(date)
|
||||
},
|
||||
remove_diatrics: function (e) { return slug(e, { mode: 'rfc3986' }) },
|
||||
site: {
|
||||
title: 'David Soulayrol'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue