fix: max lines for SB code snippets
parent
db9fb61134
commit
8a74e1abef
|
@ -16,12 +16,15 @@ interface Meta {
|
||||||
project?: string
|
project?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Protect against long code snippets
|
||||||
|
const maxLines = 20
|
||||||
|
|
||||||
const meta = $computed(() => {
|
const meta = $computed(() => {
|
||||||
const { description } = props.card
|
const { description } = props.card
|
||||||
const meta = description.match(/.+\n\nCode Snippet from (.+), lines ([\w-]+)\n\n(.+)/s)
|
const meta = description.match(/.+\n\nCode Snippet from (.+), lines ([\w-]+)\n\n(.+)/s)
|
||||||
const file = meta?.[1]
|
const file = meta?.[1]
|
||||||
const lines = meta?.[2].replaceAll('N', '')
|
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 project = props.card.title?.replace(' - StackBlitz', '')
|
||||||
const info = $ref<Meta>({
|
const info = $ref<Meta>({
|
||||||
file,
|
file,
|
||||||
|
|
Loading…
Reference in New Issue