From fabc4c18f5d016102370c3ef1bc4194e078269ac Mon Sep 17 00:00:00 2001 From: sanyuan <494130947@qq.com> Date: Sun, 9 Oct 2022 20:22:42 +0800 Subject: [PATCH] fix: unexpect html string custom head children is undefined --- src/node/build.ts | 14 +++++++++----- src/theme-default/layout/DocLayout/index.tsx | 19 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/node/build.ts b/src/node/build.ts index c61063ef..40170a17 100644 --- a/src/node/build.ts +++ b/src/node/build.ts @@ -244,7 +244,11 @@ class SSGBuilder { const attrString = Object.keys(attrs).reduce((pre, cur) => { return `${pre} ${cur}="${attrs[cur]}"`; }, ''); - return `<${tag} ${attrString}> ${children} `; + if (children === undefined || children === null) { + return `<${tag} ${attrString} />`; + } else { + return `<${tag} ${attrString}>${children}`; + } }) .join('\n'); @@ -258,10 +262,10 @@ class SSGBuilder { this.#config.siteData!.icon }" type="image/svg+xml"> ${headTag || ''} - ${helmet?.title.toString() || ''} - ${helmet?.meta.toString() || ''} - ${helmet?.link.toString() || ''} - ${helmet?.style.toString() || ''} + ${helmet?.title?.toString() || ''} + ${helmet?.meta?.toString() || ''} + ${helmet?.link?.toString() || ''} + ${helmet?.style?.toString() || ''}