From def02895045d3def6fb8dbd1a4d3a6948979c8ed Mon Sep 17 00:00:00 2001 From: Doge Gui Date: Sun, 16 Jan 2022 20:23:58 +0800 Subject: Check constructor --- scripts/feed.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/feed.js b/scripts/feed.js index edecc99..1dc4300 100644 --- a/scripts/feed.js +++ b/scripts/feed.js @@ -1,5 +1,3 @@ -'use strict'; - hexo.extend.generator.register("feed", (locals) => { // Load config @@ -10,8 +8,11 @@ hexo.extend.generator.register("feed", (locals) => { const hstrip = hexo.extend.helper.get("strip_html").bind(hexo); if (!theme.rss || !theme.rss.enable) return; - const podcast = require("podcast"); - if (podcast.hasOwnProperty('Podcast')) + let podcast = require("podcast"); + function is_constructor(obj) { + return !!obj.prototype && !!obj.prototype.constructor.name; + } + if (!is_constructor(podcast)) podcast = podcast.Podcast; // Generate Podcast Categories content -- cgit v1.2.3