diff --git a/tool_core.js b/tool_core.js index f8061de..41cca3b 100644 --- a/tool_core.js +++ b/tool_core.js @@ -332,23 +332,24 @@ module.exports = { // 返回新的数组 filter_story (story) { if (Array.isArray(story) && story.length) { - // section can contain property '_xxx' which shall not change filter result. return story.filter((section) => { if (!section) return false - return Object.entries(section).some(([key, val]) => !key.startsWith('_') && !this.is_empty(val)) + return Object.values(section).some((val) => !this.is_empty(val)) + //return Object.entries(section).some(([key, val]) => !key.startsWith('_') && !this.is_empty(val)) // don't check properties '_xxx' }) } else { return [] } }, + // 20250621 todo 如果 text 是 {enUS,zhCN} 怎么处理 extract_story_title (story) { if (Array.isArray(story) && story.length) { return ( story - .map(({ text = '' } = {}) => text.trim().replace(/\n/g, ' ')) - .join(' ') - .substring(0, 140) || '' + .map(({ text = '' } = {}) => text.trim?.()?.replace?.(/\n/g, ' ')) + ?.join(' ') + ?.substring?.(0, 140) || '' ) } else { return ''