From 8a74e1abef742f4421f90d942b15c079d8b2a60b Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 17 Jan 2023 12:47:52 +0100 Subject: [PATCH] fix: max lines for SB code snippets --- components/status/StatusPreviewStackBlitz.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/status/StatusPreviewStackBlitz.vue b/components/status/StatusPreviewStackBlitz.vue index c23039bb..9a5b565d 100644 --- a/components/status/StatusPreviewStackBlitz.vue +++ b/components/status/StatusPreviewStackBlitz.vue @@ -16,12 +16,15 @@ interface Meta { project?: string } +// Protect against long code snippets +const maxLines = 20 + const meta = $computed(() => { const { description } = props.card const meta = description.match(/.+\n\nCode Snippet from (.+), lines ([\w-]+)\n\n(.+)/s) const file = meta?.[1] const lines = meta?.[2].replaceAll('N', '') - const code = meta?.[3] + const code = meta?.[3].split('\n').slice(0, maxLines).join('\n') const project = props.card.title?.replace(' - StackBlitz', '') const info = $ref({ file,