[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 SSRComponentMetadata = {
|
||||
propagation: PropagationHint,
|
||||
containsHead: boolean
|
||||
propagation: PropagationHint;
|
||||
containsHead: boolean;
|
||||
};
|
||||
|
||||
export interface SSRResult {
|
||||
|
|
|
@ -178,13 +178,7 @@ async function render({
|
|||
|
||||
return createHeadAndContent(
|
||||
unescapeHTML(styles + links + scripts) as any,
|
||||
renderTemplate`${renderComponent(
|
||||
result,
|
||||
'Content',
|
||||
mod.Content,
|
||||
props,
|
||||
slots
|
||||
)}`
|
||||
renderTemplate`${renderComponent(result, 'Content', mod.Content, props, slots)}`
|
||||
);
|
||||
},
|
||||
propagation: 'self',
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
|
||||
import type {
|
||||
ComponentInstance,
|
||||
SSRComponentMetadata,
|
||||
RouteData,
|
||||
SerializedRouteData,
|
||||
SSRComponentMetadata,
|
||||
SSRLoadedRenderer,
|
||||
SSRResult,
|
||||
} from '../../@types/astro';
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import type { GetModuleInfo, ModuleInfo } from 'rollup';
|
||||
import type { ViteDevServer } from 'vite';
|
||||
|
||||
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';
|
||||
|
||||
|
@ -24,16 +24,13 @@ export async function getComponentMetadata(
|
|||
return map;
|
||||
}
|
||||
|
||||
function addMetadata(
|
||||
map: SSRResult['componentMetadata'],
|
||||
modInfo: ModuleInfo | null
|
||||
) {
|
||||
function addMetadata(map: SSRResult['componentMetadata'], modInfo: ModuleInfo | null) {
|
||||
if (modInfo) {
|
||||
const astro = getAstroMetadata(modInfo);
|
||||
if (astro) {
|
||||
let metadata: SSRComponentMetadata = {
|
||||
containsHead: false,
|
||||
propagation: 'none'
|
||||
propagation: 'none',
|
||||
};
|
||||
if (astro.propagation) {
|
||||
metadata.propagation = astro.propagation;
|
||||
|
|
|
@ -9,11 +9,7 @@ import type {
|
|||
SSRLoadedRenderer,
|
||||
SSRResult,
|
||||
} from '../../@types/astro';
|
||||
import {
|
||||
renderSlot,
|
||||
stringifyChunk,
|
||||
type ComponentSlots,
|
||||
} from '../../runtime/server/index.js';
|
||||
import { renderSlot, stringifyChunk, type ComponentSlots } from '../../runtime/server/index.js';
|
||||
import { renderJSX } from '../../runtime/server/jsx.js';
|
||||
import { AstroCookies } from '../cookies/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
|
||||
// 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 factoryIsHeadAndContent = isHeadAndContent(factoryReturnValue);
|
||||
if (isRenderTemplateResult(factoryReturnValue) || factoryIsHeadAndContent) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type * as vite from 'vite';
|
||||
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 { StaticBuildOptions } from '../core/build/types';
|
||||
import type { PluginMetadata } from '../vite-plugin-astro/types';
|
||||
|
@ -21,13 +21,19 @@ export default function configHeadVitePlugin({
|
|||
function propagateMetadata<
|
||||
P extends keyof PluginMetadata['astro'],
|
||||
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;
|
||||
seen.add(id);
|
||||
const mod = server.moduleGraph.getModuleById(id);
|
||||
const info = this.getModuleInfo(id);
|
||||
if (info?.meta.astro) {
|
||||
const astroMetadata = getAstroMetadata(info)
|
||||
const astroMetadata = getAstroMetadata(info);
|
||||
if (astroMetadata) {
|
||||
Reflect.set(astroMetadata, prop, value);
|
||||
}
|
||||
|
@ -40,7 +46,6 @@ export default function configHeadVitePlugin({
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
name: 'astro:head-metadata',
|
||||
configureServer(_server) {
|
||||
|
@ -80,7 +85,7 @@ export function astroHeadBuildPlugin(
|
|||
if (map.has(id)) return map.get(id)!;
|
||||
const metadata: SSRComponentMetadata = {
|
||||
propagation: 'none',
|
||||
containsHead: false
|
||||
containsHead: false,
|
||||
};
|
||||
map.set(id, metadata);
|
||||
return metadata;
|
||||
|
|
Loading…
Reference in a new issue