Skip to content

Commit

Permalink
fix(titleTemplate): avoid non-title template error
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Nov 8, 2022
1 parent 912b508 commit b35871c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/zhead/src/titleTemplate.ts
Expand Up @@ -15,14 +15,13 @@ export const renderTitleTemplate = (
export function resolveTitleTemplateFromTags(tags: HeadTag[]) {
const titleTemplateIdx = tags.findIndex(i => i.tag === 'titleTemplate')
const titleIdx = tags.findIndex(i => i.tag === 'title')
const title = tags[titleIdx].children
if (titleIdx !== -1 && titleTemplateIdx !== -1) {
const newTitle = renderTitleTemplate(
tags[titleTemplateIdx].children!,
title,
tags[titleIdx].children,
)
if (newTitle !== null) {
tags[titleIdx].children = newTitle || title
tags[titleIdx].children = newTitle || tags[titleIdx].children
}
else {
// remove the title tag
Expand Down

0 comments on commit b35871c

Please sign in to comment.