Skip to content

Commit ca55bff

Browse files
authored
fix(bff): handle no classes set on the code element (#351)
1 parent c86cc85 commit ca55bff

File tree

1 file changed

+2
-2
lines changed
  • libs/blog-bff/articles/api/src/lib

1 file changed

+2
-2
lines changed

libs/blog-bff/articles/api/src/lib/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { CheerioAPI } from 'cheerio';
12
import { createHighlighterCore } from 'shiki/core';
23
import { loadWasm } from 'shiki/engine/oniguruma';
3-
import type { CheerioAPI } from 'cheerio';
44

55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore
@@ -53,7 +53,7 @@ export const wpCodeRewriter: RewriteAdapter = ($) => {
5353
}
5454

5555
const classAttr = $(element).find('code').attr()['class'];
56-
const classes = classAttr.split(' ');
56+
const classes = classAttr?.split(' ') ?? [];
5757
const codeLanguageClass = classes.find((cl) =>
5858
/^language-[\w-]+$/.test(cl),
5959
);

0 commit comments

Comments
 (0)