forked from ti-nuage/site
Mise en évidence automatique des liens externes.
Ceci concerne uniquement le traitement des fichiers Markdown (il est toujours nécessaire de traiter manuellement les sources écrites en HTML). Pour réaliser cette fonction, le plugin metalsmith-mardownit a été remplacé par @metalsmith/markdown.
This commit is contained in:
@@ -7,7 +7,8 @@ const excerpts = require('@metalsmith/excerpts')
|
||||
const groff = require('metalsmith-groff')
|
||||
const layouts = require('@metalsmith/layouts')
|
||||
const Metalsmith = require('metalsmith')
|
||||
const markdown = require('metalsmith-markdownit')
|
||||
const markdown = require('@metalsmith/markdown')
|
||||
const marked = require('marked')
|
||||
const moment = require('moment')
|
||||
const permalinks = require('@metalsmith/permalinks')
|
||||
const rename = require('metalsmith-rename')
|
||||
@@ -17,6 +18,20 @@ const statistics = require('./metalsmith-statistics-plugin')
|
||||
|
||||
const __PROD__ = process.env.NODE_ENV === 'production'
|
||||
|
||||
const markdownRenderer = new marked.Renderer()
|
||||
|
||||
const m = markdownRenderer.link
|
||||
|
||||
markdownRenderer.link = function (href, title, text) {
|
||||
let out = m.apply(this, [href, title, text])
|
||||
|
||||
if (href.startsWith('http') && !href.match('^https?://(www.)?ti-nuage\\.fr/.*')) {
|
||||
out = out.slice(0, 3) + ' class="external" ' + out.slice(3)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
moment.locale('fr')
|
||||
|
||||
module.exports = new Metalsmith(config.paths.projectRoot)
|
||||
@@ -43,14 +58,11 @@ module.exports = new Metalsmith(config.paths.projectRoot)
|
||||
}))
|
||||
.use(groff())
|
||||
.use(markdown({
|
||||
html: true,
|
||||
linkify: true,
|
||||
typographer: true,
|
||||
quotes: ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'],
|
||||
plugin: {
|
||||
pattern: '**/*.md',
|
||||
extension: 'html'
|
||||
}
|
||||
gfm: false,
|
||||
headerIds: false,
|
||||
renderer: markdownRenderer,
|
||||
smartypants: true,
|
||||
xhtml: true
|
||||
}))
|
||||
.use(excerpts())
|
||||
.use(permalinks({
|
||||
|
||||
Reference in New Issue
Block a user