mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
Inline responseCodiMD
Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
ca9e6e49c9
commit
3c39d07723
1 changed files with 14 additions and 18 deletions
|
@ -64,7 +64,20 @@ exports.showNote = function (req, res, next) {
|
||||||
if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) {
|
if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) {
|
||||||
return res.redirect(config.serverURL + '/' + (note.alias || id))
|
return res.redirect(config.serverURL + '/' + (note.alias || id))
|
||||||
}
|
}
|
||||||
return responseCodiMD(res, note)
|
const body = note.content
|
||||||
|
const extracted = models.Note.extractMeta(body)
|
||||||
|
const meta = models.Note.parseMeta(extracted.meta)
|
||||||
|
let title = models.Note.decodeTitle(note.title)
|
||||||
|
title = models.Note.generateWebTitle(meta.title || title)
|
||||||
|
const opengraph = models.Note.parseOpengraph(meta, title)
|
||||||
|
res.set({
|
||||||
|
'Cache-Control': 'private', // only cache by client
|
||||||
|
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
|
||||||
|
})
|
||||||
|
return res.render('codimd.ejs', {
|
||||||
|
title: title,
|
||||||
|
opengraph: opengraph
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,20 +145,3 @@ exports.downloadMarkdown = function (req, res, note) {
|
||||||
})
|
})
|
||||||
res.send(body)
|
res.send(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
function responseCodiMD (res, note) {
|
|
||||||
const body = note.content
|
|
||||||
const extracted = models.Note.extractMeta(body)
|
|
||||||
const meta = models.Note.parseMeta(extracted.meta)
|
|
||||||
let title = models.Note.decodeTitle(note.title)
|
|
||||||
title = models.Note.generateWebTitle(meta.title || title)
|
|
||||||
const opengraph = models.Note.parseOpengraph(meta, title)
|
|
||||||
res.set({
|
|
||||||
'Cache-Control': 'private', // only cache by client
|
|
||||||
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
|
|
||||||
})
|
|
||||||
res.render('codimd.ejs', {
|
|
||||||
title: title,
|
|
||||||
opengraph: opengraph
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue