Skip to content

Commit

Permalink
feat(nuxt): enable omitLineBreaks configuration for @unhead
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini-ghost committed Apr 29, 2024
1 parent 4544eaf commit 6ca5905
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/nuxt/src/core/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
'process.env.NUXT_JSON_PAYLOADS': !!nuxt.options.experimental.renderJsonPayloads,
'process.env.NUXT_ASYNC_CONTEXT': !!nuxt.options.experimental.asyncContext,
'process.env.NUXT_SHARED_DATA': !!nuxt.options.experimental.sharedPrerenderData,
'process.env.NUXT_OMIT_LINE_BREAKS': !!nuxt.options.features.omitLineBreaks,
'process.dev': nuxt.options.dev,
'__VUE_PROD_DEVTOOLS__': false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/core/runtime/nitro/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
}

// remove certain tags for nuxt islands
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(head)
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(head, process.env.NUXT_OMIT_LINE_BREAKS ? { omitLineBreaks: true } : undefined)

// Create render context
const htmlContext: NuxtRenderHTMLContext = {
Expand Down
12 changes: 12 additions & 0 deletions packages/schema/src/config/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ export default defineUntypedSchema({
return val ?? await (get('experimental') as Promise<Record<string, any>>).then((e: Record<string, any>) => e?.noScripts) ?? false
},
},

/**
* Set `omitLineBreaks` to `true` if you prefer to render the head tags without line breaks.
*
* @type {boolean}
*/
omitLineBreaks: {
$resolve (val) {
if (val === undefined) { return false }
return val
},
},
},
experimental: {
/**
Expand Down

0 comments on commit 6ca5905

Please sign in to comment.