Skip to content

Commit c531d96

Browse files
committed
check if reveal theme exists
1 parent e5834c0 commit c531d96

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/response.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var moment = require('moment')
1313
var config = require('./config')
1414
var logger = require('./logger')
1515
var models = require('./models')
16+
var utils = require('./utils')
1617

1718
// public
1819
var response = {
@@ -574,7 +575,7 @@ function showPublishSlide (req, res, next) {
574575
updatetime: updatetime,
575576
url: origin,
576577
body: markdown,
577-
theme: meta.slideOptions.theme,
578+
theme: utils.isRevealTheme(meta.slideOptions.theme),
578579
meta: JSON.stringify(extracted.meta),
579580
useCDN: config.usecdn,
580581
owner: note.owner ? note.owner.id : null,

lib/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
'use strict'
2+
const fs = require('fs')
3+
const path = require('path')
24

35
exports.isSQLite = function isSQLite (sequelize) {
46
return sequelize.options.dialect === 'sqlite'
@@ -23,3 +25,10 @@ exports.getImageMimeType = function getImageMimeType (imagePath) {
2325
return undefined
2426
}
2527
}
28+
29+
exports.isRevealTheme = function isRevealTheme (theme) {
30+
if (fs.existsSync(path.join(process.cwd(), 'public', 'build', 'reveal.js', 'css', 'theme', theme + '.css'))) {
31+
return theme
32+
}
33+
return undefined
34+
}

0 commit comments

Comments
 (0)