@@ -36,6 +36,10 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
3636 * Leverage other plugins
3737 */
3838 const plugins : any [ ] [ ] = [ ] ;
39+ const services = {
40+ comment : { enabled : false , service : '' } ,
41+ email : { enabled : false } ,
42+ } ;
3943
4044 if ( options . sitemap && options . sitemap . hostname ) {
4145 const defaultSitemapOptions = { exclude : [ '/404.html' ] } ;
@@ -56,9 +60,13 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
5660 switch ( commentService ) {
5761 case 'vssue' :
5862 plugins . push ( [ '@vssue/vuepress-plugin-vssue' , commentOptions ] ) ;
63+ services . comment . enabled = true ;
64+ services . comment . service = commentService ;
5965 break ;
6066 case 'disqus' :
6167 plugins . push ( [ 'vuepress-plugin-disqus-comment' , commentOptions ] ) ;
68+ services . comment . enabled = true ;
69+ services . comment . service = commentService ;
6270 break ;
6371 default :
6472 logger . warn (
@@ -70,12 +78,9 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
7078 }
7179 }
7280
73- const isNewsletterEnabled = ! ! (
74- options . newsletter && options . newsletter . endpoint
75- ) ;
76-
77- if ( isNewsletterEnabled ) {
81+ if ( ! ! ( options . newsletter && options . newsletter . endpoint ) ) {
7882 plugins . push ( [ 'vuepress-plugin-mailchimp' , options . newsletter ] ) ;
83+ services . email . enabled = true ;
7984 }
8085
8186 return {
@@ -240,20 +245,20 @@ export default ${serializePaginations(ctx.serializedPaginations, [
240245 name : `${ PREFIX } /pageSorters.js` ,
241246 content : `export default ${ mapToString ( ctx . pageSorters , true ) } ` ,
242247 } ,
248+ {
249+ name : `${ PREFIX } /services.js` ,
250+ content : `export default ${ JSON . stringify ( services , null , 2 ) } ` ,
251+ } ,
243252 ] ;
244253 } ,
245254
246255 enhanceAppFiles : [
247256 path . resolve ( __dirname , '../client/classification.js' ) ,
248257 path . resolve ( __dirname , '../client/pagination.js' ) ,
258+ path . resolve ( __dirname , '../client/services.js' ) ,
249259 ] ,
250260
251261 plugins,
252-
253- define : {
254- COMMENT_SERVICE : options . comment && options . comment . service ,
255- IS_NEWSLETTER_ENABLED : isNewsletterEnabled ,
256- } ,
257262 } ;
258263} ;
259264
0 commit comments