summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/web/note/controller.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/web/note/controller.js b/lib/web/note/controller.js
index 3641f6b1..e537fe08 100644
--- a/lib/web/note/controller.js
+++ b/lib/web/note/controller.js
@@ -64,7 +64,20 @@ exports.showNote = function (req, res, next) {
if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== 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)
}
-
-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
- })
-}