diff --git a/.changeset/angry-pants-retire.md b/.changeset/angry-pants-retire.md new file mode 100644 index 000000000..724b976b4 --- /dev/null +++ b/.changeset/angry-pants-retire.md @@ -0,0 +1,5 @@ +--- +'@rspress/theme-default': major +--- + +prevent hero's some fields from not being strings diff --git a/packages/rspress-theme-default/src/theme-default/logic/utils.ts b/packages/rspress-theme-default/src/theme-default/logic/utils.ts index c0688b17e..4a0c88e58 100644 --- a/packages/rspress-theme-default/src/theme-default/logic/utils.ts +++ b/packages/rspress-theme-default/src/theme-default/logic/utils.ts @@ -3,6 +3,7 @@ import React from 'react'; import htmr from 'htmr'; import isHtml from 'is-html'; import { isEqualPath } from '@rspress/runtime'; +import { isNull, isNumber } from 'lodash-es'; export function isActive( currentPath: string, @@ -41,6 +42,10 @@ export function isMobileDevice() { return window.innerWidth < 768; } -export function renderHtmlOrText(str: string) { +export function renderHtmlOrText(str: string | number | null) { + if (isNull(str) || isNumber(str)) { + return str; + } + return isHtml(str) ? htmr(str) : str; }