Skip to content

Commit

Permalink
fix: prevent hero's some fields from not being strings
Browse files Browse the repository at this point in the history
  • Loading branch information
FireBushtree committed Oct 27, 2023
1 parent 5ba3dd9 commit e21f6d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/angry-pants-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rspress/theme-default': major
---

prevent hero's some fields from not being strings
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

0 comments on commit e21f6d7

Please sign in to comment.