From 93b739662e00b0bccc06afd7687fd3e8716d3dec Mon Sep 17 00:00:00 2001 From: harlan Date: Sun, 19 Jan 2025 12:17:31 +1100 Subject: [PATCH] fix(content): avoid parsing invalid videos in markdown --- src/runtime/server/plugins/nuxt-content-v2.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/runtime/server/plugins/nuxt-content-v2.ts b/src/runtime/server/plugins/nuxt-content-v2.ts index 3460a51..c4ddc12 100644 --- a/src/runtime/server/plugins/nuxt-content-v2.ts +++ b/src/runtime/server/plugins/nuxt-content-v2.ts @@ -6,7 +6,7 @@ import { useSimpleSitemapRuntimeConfig } from '../utils' import { defineNitroPlugin } from '#imports' export default defineNitroPlugin((nitroApp: NitroApp) => { - const { discoverImages, discoverVideos, isNuxtContentDocumentDriven } = useSimpleSitemapRuntimeConfig() + const { discoverImages, isNuxtContentDocumentDriven } = useSimpleSitemapRuntimeConfig() // @ts-expect-error untyped nitroApp.hooks.hook('content:file:afterParse', async (content: ParsedContent) => { const validExtensions = ['md', 'mdx'] @@ -23,16 +23,6 @@ export default defineNitroPlugin((nitroApp: NitroApp) => { .map(i => ({ loc: i.props!.src })) || []) } - // add any top level videos - let videos: SitemapUrl['videos'] = [] - if (discoverVideos) { - videos = (content.body?.children - ?.filter(c => - c.tag && c.props?.src && ['video'].includes(c.tag.toLowerCase()), - ) - .map(i => ({ content_loc: i.props!.src })) || []) - } - const sitemapConfig = typeof content.sitemap === 'object' ? content.sitemap : {} const lastmod = content.modifiedAt || content.updatedAt const defaults: Partial = {} @@ -40,10 +30,8 @@ export default defineNitroPlugin((nitroApp: NitroApp) => { defaults.loc = content._path if (content.path) // automatically set when document driven defaults.loc = content.path - if (images.length > 0) + if (images?.length) defaults.images = images - if (videos.length > 0) - defaults.videos = videos if (lastmod) defaults.lastmod = lastmod const definition = defu(sitemapConfig, defaults) as Partial