[ci] format
This commit is contained in:
parent
45da39a864
commit
b558bd5140
9 changed files with 35 additions and 43 deletions
|
@ -1594,8 +1594,8 @@ export interface SSRMetadata {
|
||||||
export type PropagationHint = 'none' | 'self' | 'in-tree';
|
export type PropagationHint = 'none' | 'self' | 'in-tree';
|
||||||
|
|
||||||
export type SSRComponentMetadata = {
|
export type SSRComponentMetadata = {
|
||||||
propagation: PropagationHint,
|
propagation: PropagationHint;
|
||||||
containsHead: boolean
|
containsHead: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface SSRResult {
|
export interface SSRResult {
|
||||||
|
|
|
@ -178,13 +178,7 @@ async function render({
|
||||||
|
|
||||||
return createHeadAndContent(
|
return createHeadAndContent(
|
||||||
unescapeHTML(styles + links + scripts) as any,
|
unescapeHTML(styles + links + scripts) as any,
|
||||||
renderTemplate`${renderComponent(
|
renderTemplate`${renderComponent(result, 'Content', mod.Content, props, slots)}`
|
||||||
result,
|
|
||||||
'Content',
|
|
||||||
mod.Content,
|
|
||||||
props,
|
|
||||||
slots
|
|
||||||
)}`
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
propagation: 'self',
|
propagation: 'self',
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
|
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
|
||||||
import type {
|
import type {
|
||||||
ComponentInstance,
|
ComponentInstance,
|
||||||
SSRComponentMetadata,
|
|
||||||
RouteData,
|
RouteData,
|
||||||
SerializedRouteData,
|
SerializedRouteData,
|
||||||
|
SSRComponentMetadata,
|
||||||
SSRLoadedRenderer,
|
SSRLoadedRenderer,
|
||||||
SSRResult,
|
SSRResult,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import type { GetModuleInfo, ModuleInfo } from 'rollup';
|
import type { GetModuleInfo, ModuleInfo } from 'rollup';
|
||||||
import type { ViteDevServer } from 'vite';
|
|
||||||
|
|
||||||
import { resolvedPagesVirtualModuleId } from '../app/index.js';
|
import { resolvedPagesVirtualModuleId } from '../app/index.js';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { SSRResult, SSRComponentMetadata } from '../../../@types/astro';
|
import type { SSRComponentMetadata, SSRResult } from '../../../@types/astro';
|
||||||
|
|
||||||
import type { ModuleInfo, ModuleLoader } from '../../module-loader/index';
|
import type { ModuleInfo, ModuleLoader } from '../../module-loader/index';
|
||||||
|
|
||||||
|
@ -24,16 +24,13 @@ export async function getComponentMetadata(
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMetadata(
|
function addMetadata(map: SSRResult['componentMetadata'], modInfo: ModuleInfo | null) {
|
||||||
map: SSRResult['componentMetadata'],
|
|
||||||
modInfo: ModuleInfo | null
|
|
||||||
) {
|
|
||||||
if (modInfo) {
|
if (modInfo) {
|
||||||
const astro = getAstroMetadata(modInfo);
|
const astro = getAstroMetadata(modInfo);
|
||||||
if (astro) {
|
if (astro) {
|
||||||
let metadata: SSRComponentMetadata = {
|
let metadata: SSRComponentMetadata = {
|
||||||
containsHead: false,
|
containsHead: false,
|
||||||
propagation: 'none'
|
propagation: 'none',
|
||||||
};
|
};
|
||||||
if (astro.propagation) {
|
if (astro.propagation) {
|
||||||
metadata.propagation = astro.propagation;
|
metadata.propagation = astro.propagation;
|
||||||
|
|
|
@ -9,11 +9,7 @@ import type {
|
||||||
SSRLoadedRenderer,
|
SSRLoadedRenderer,
|
||||||
SSRResult,
|
SSRResult,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
import {
|
import { renderSlot, stringifyChunk, type ComponentSlots } from '../../runtime/server/index.js';
|
||||||
renderSlot,
|
|
||||||
stringifyChunk,
|
|
||||||
type ComponentSlots,
|
|
||||||
} from '../../runtime/server/index.js';
|
|
||||||
import { renderJSX } from '../../runtime/server/jsx.js';
|
import { renderJSX } from '../../runtime/server/jsx.js';
|
||||||
import { AstroCookies } from '../cookies/index.js';
|
import { AstroCookies } from '../cookies/index.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError, AstroErrorData } from '../errors/index.js';
|
||||||
|
|
|
@ -125,7 +125,8 @@ export async function renderPage(
|
||||||
}
|
}
|
||||||
// Mark if this page component contains a <head> within its tree. If it does
|
// Mark if this page component contains a <head> within its tree. If it does
|
||||||
// We avoid implicit head injection entirely.
|
// We avoid implicit head injection entirely.
|
||||||
result._metadata.headInTree = result.componentMetadata.get(componentFactory.moduleId!)?.containsHead ?? false;
|
result._metadata.headInTree =
|
||||||
|
result.componentMetadata.get(componentFactory.moduleId!)?.containsHead ?? false;
|
||||||
const factoryReturnValue = await componentFactory(result, props, children);
|
const factoryReturnValue = await componentFactory(result, props, children);
|
||||||
const factoryIsHeadAndContent = isHeadAndContent(factoryReturnValue);
|
const factoryIsHeadAndContent = isHeadAndContent(factoryReturnValue);
|
||||||
if (isRenderTemplateResult(factoryReturnValue) || factoryIsHeadAndContent) {
|
if (isRenderTemplateResult(factoryReturnValue) || factoryIsHeadAndContent) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type * as vite from 'vite';
|
|
||||||
import type { ModuleInfo } from 'rollup';
|
import type { ModuleInfo } from 'rollup';
|
||||||
import type { AstroSettings, SSRResult, SSRComponentMetadata } from '../@types/astro';
|
import type * as vite from 'vite';
|
||||||
|
import type { AstroSettings, SSRComponentMetadata, SSRResult } from '../@types/astro';
|
||||||
import type { AstroBuildPlugin } from '../core/build/plugin.js';
|
import type { AstroBuildPlugin } from '../core/build/plugin.js';
|
||||||
import type { StaticBuildOptions } from '../core/build/types';
|
import type { StaticBuildOptions } from '../core/build/types';
|
||||||
import type { PluginMetadata } from '../vite-plugin-astro/types';
|
import type { PluginMetadata } from '../vite-plugin-astro/types';
|
||||||
|
@ -21,13 +21,19 @@ export default function configHeadVitePlugin({
|
||||||
function propagateMetadata<
|
function propagateMetadata<
|
||||||
P extends keyof PluginMetadata['astro'],
|
P extends keyof PluginMetadata['astro'],
|
||||||
V extends PluginMetadata['astro'][P]
|
V extends PluginMetadata['astro'][P]
|
||||||
>(this: { getModuleInfo(id: string): ModuleInfo | null }, id: string, prop: P, value: V, seen = new Set<string>()) {
|
>(
|
||||||
|
this: { getModuleInfo(id: string): ModuleInfo | null },
|
||||||
|
id: string,
|
||||||
|
prop: P,
|
||||||
|
value: V,
|
||||||
|
seen = new Set<string>()
|
||||||
|
) {
|
||||||
if (seen.has(id)) return;
|
if (seen.has(id)) return;
|
||||||
seen.add(id);
|
seen.add(id);
|
||||||
const mod = server.moduleGraph.getModuleById(id);
|
const mod = server.moduleGraph.getModuleById(id);
|
||||||
const info = this.getModuleInfo(id);
|
const info = this.getModuleInfo(id);
|
||||||
if (info?.meta.astro) {
|
if (info?.meta.astro) {
|
||||||
const astroMetadata = getAstroMetadata(info)
|
const astroMetadata = getAstroMetadata(info);
|
||||||
if (astroMetadata) {
|
if (astroMetadata) {
|
||||||
Reflect.set(astroMetadata, prop, value);
|
Reflect.set(astroMetadata, prop, value);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +46,6 @@ export default function configHeadVitePlugin({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'astro:head-metadata',
|
name: 'astro:head-metadata',
|
||||||
configureServer(_server) {
|
configureServer(_server) {
|
||||||
|
@ -80,7 +85,7 @@ export function astroHeadBuildPlugin(
|
||||||
if (map.has(id)) return map.get(id)!;
|
if (map.has(id)) return map.get(id)!;
|
||||||
const metadata: SSRComponentMetadata = {
|
const metadata: SSRComponentMetadata = {
|
||||||
propagation: 'none',
|
propagation: 'none',
|
||||||
containsHead: false
|
containsHead: false,
|
||||||
};
|
};
|
||||||
map.set(id, metadata);
|
map.set(id, metadata);
|
||||||
return metadata;
|
return metadata;
|
||||||
|
|
Loading…
Add table
Reference in a new issue