-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional scoping for head buffering
- Loading branch information
Showing
17 changed files
with
118 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { SSRResult } from '../../../@types/astro'; | ||
|
||
export const ScopeFlags = { | ||
Astro: 1 << 0, // 1 | ||
JSX: 1 << 1, // 2 | ||
Slot: 1 << 2, // 4 | ||
HeadBuffer: 1 << 3, // 8 | ||
} as const; | ||
|
||
type ScopeFlagValues = (typeof ScopeFlags)[keyof typeof ScopeFlags]; | ||
|
||
export function addScopeFlag(result: SSRResult, flag: ScopeFlagValues) { | ||
result.scope |= flag; | ||
} | ||
|
||
export function removeScopeFlag(result: SSRResult, flag: ScopeFlagValues) { | ||
result.scope &= ~flag; | ||
} | ||
|
||
export function createScopedResult(result: SSRResult, flag?: ScopeFlagValues): SSRResult { | ||
const scopedResult = Object.create(result, { | ||
scope: { | ||
writable: true, | ||
value: result.scope | ||
} | ||
}); | ||
if(flag != null) { | ||
addScopeFlag(scopedResult, flag); | ||
} | ||
return scopedResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/integrations/mdx/test/fixtures/css-head-mdx/src/components/SmallCaps.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
--- | ||
<span style={{fontVariant: "small-caps"}}><slot /></span> |
5 changes: 5 additions & 0 deletions
5
packages/integrations/mdx/test/fixtures/css-head-mdx/src/content/posts/test.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: Testing | ||
--- | ||
|
||
<SmallCaps>A test file</SmallCaps> |
24 changes: 24 additions & 0 deletions
24
packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/ContentLayout.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
export interface Props { | ||
title: string; | ||
} | ||
const { title } = Astro.props; | ||
--- | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> | ||
<meta name="generator" content={Astro.generator} /> | ||
<title>{title}</title> | ||
<style is:global> | ||
@import "../styles/global.css"; | ||
</style> | ||
</head> | ||
<body> | ||
<slot /> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/posts/[post].astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
import { getCollection } from 'astro:content'; | ||
import Layout from '../../layouts/ContentLayout.astro'; | ||
import SmallCaps from '../../components/SmallCaps.astro'; | ||
export async function getStaticPaths() { | ||
const entries = await getCollection('posts'); | ||
return entries.map(entry => { | ||
return {params: { post: entry.slug }, props: { entry }, | ||
}}); | ||
} | ||
const { entry } = Astro.props; | ||
const { Content } = await entry.render(); | ||
--- | ||
<Layout title=""> | ||
<Content components={{ SmallCaps }} /> | ||
</Layout> |
3 changes: 3 additions & 0 deletions
3
packages/integrations/mdx/test/fixtures/css-head-mdx/src/styles/global.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
html { | ||
font-weight: bolder; | ||
} |