Updating codeExample logic to account for when there is no CSS in the code examples

This commit is contained in:
Sana Javed 2023-05-22 17:15:52 +02:00
parent a94340d10a
commit 43d62b6bef

View File

@ -263,9 +263,9 @@ const getCanSplit = (
const exampleSourceLengths = [...scssExamples, ...sassExamples].flatMap( const exampleSourceLengths = [...scssExamples, ...sassExamples].flatMap(
(source) => source.split('\n').map((line) => line.length), (source) => source.split('\n').map((line) => line.length),
); );
const cssSourceLengths = cssExamples.flatMap((source) => const cssSourceLengths = cssExamples.length ? cssExamples.flatMap((source) =>
source.split('\n').map((line) => line.length), source.split('\n').map((line) => line.length),
); ) : [0];
const maxSourceWidth = Math.max(...exampleSourceLengths); const maxSourceWidth = Math.max(...exampleSourceLengths);
const maxCSSWidth = Math.max(...cssSourceLengths); const maxCSSWidth = Math.max(...cssSourceLengths);