1- import type { RenderSSRHeadOptions , Unhead } from '../types'
1+ import type { SSRHeadPayload , Unhead } from '../types'
22import { applyHeadToHtml , parseHtmlForIndexes , parseHtmlForUnheadExtraction } from '../parser'
3- import { renderSSRHead } from './renderSSRHead'
43
54/**
65 * Transform an HTML template string by extracting any head tags and attributes from it, pushing them to Unhead,
76 * and injecting the resulting head tags back into the HTML.
87 * Uses optimized parsing and index-based HTML construction for best performance.
98 */
109/* @__NO_SIDE_EFFECTS__ */
11- export async function transformHtmlTemplate ( head : Unhead < any > , html : string , options ?: RenderSSRHeadOptions ) {
10+ export function transformHtmlTemplate ( head : Unhead < any , SSRHeadPayload > , html : string ) {
1211 const template = parseHtmlForUnheadExtraction ( html )
1312 head . push ( template . input , { _index : 0 } )
14- const headHtml = renderSSRHead ( head , options )
15- return applyHeadToHtml ( template , headHtml )
13+ return applyHeadToHtml ( template , head . render ( ) )
1614}
1715
1816/**
@@ -25,9 +23,8 @@ export async function transformHtmlTemplate(head: Unhead<any>, html: string, opt
2523 * ordered incorrectly, so use with caution.
2624 */
2725/* @__NO_SIDE_EFFECTS__ */
28- export async function transformHtmlTemplateRaw ( head : Unhead < any > , html : string , options ?: RenderSSRHeadOptions ) {
29- const headHtml = renderSSRHead ( head , options )
26+ export function transformHtmlTemplateRaw ( head : Unhead < any , SSRHeadPayload > , html : string ) {
3027 // For raw mode, we only need indexes, not head extraction
3128 const template = parseHtmlForIndexes ( html )
32- return applyHeadToHtml ( template , headHtml )
29+ return applyHeadToHtml ( template , head . render ( ) )
3330}
0 commit comments