Update examples to move away from Astro.resolve on styles (#2393)
* Update examples to move away from Astro.resolve on styles * Prepend the subpath * Adds a changeset * Switch to @import for the starter
This commit is contained in:
parent
672b831940
commit
bcc617f9dc
9 changed files with 32 additions and 12 deletions
5
.changeset/flat-tips-happen.md
Normal file
5
.changeset/flat-tips-happen.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Prepends site subpath when using --experimental-static-build
|
|
@ -18,7 +18,9 @@ const { title, description, image, type, next, prev, canonicalURL } = Astro.prop
|
|||
<meta name="description" content={description} />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet" />
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/global.css')} />
|
||||
<style global>
|
||||
@import "../styles/global.css";
|
||||
</style>
|
||||
<!-- Sitemap -->
|
||||
<link rel="sitemap" href="/sitemap.xml" />
|
||||
<!-- RSS -->
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
<link rel="sitemap" href="/sitemap.xml" />
|
||||
|
||||
<!-- Global CSS -->
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/theme.css')} />
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/code.css')} />
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/index.css')} />
|
||||
<style global>
|
||||
@import "../styles/theme.css";
|
||||
@import "../styles/code.css";
|
||||
@import "../styles/index.css";
|
||||
</style>
|
||||
|
||||
<!-- Preload Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
|
|
|
@ -17,7 +17,9 @@ import SvelteCounter from '../components/SvelteCounter.svelte';
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href={Astro.resolve('../styles/global.css')} />
|
||||
<style global>
|
||||
@import "../styles/global.css";
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
|
|
|
@ -20,8 +20,10 @@ let title = 'My Astro Site';
|
|||
<title>{title}</title>
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/global.css')}>
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/home.css')}>
|
||||
<style global>
|
||||
@import "../styles/global.css";
|
||||
@import "../styles/home.css";
|
||||
</style>
|
||||
|
||||
<style>
|
||||
header {
|
||||
|
|
|
@ -9,7 +9,9 @@ const { content } = Astro.props;
|
|||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
|
||||
<title>{content.title}</title>
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/global.css')} />
|
||||
<style global>
|
||||
@import "../styles/global.css";
|
||||
</style>
|
||||
<style>
|
||||
.nav {
|
||||
border-bottom: 1px solid #ccc;
|
||||
|
|
|
@ -9,7 +9,9 @@ const { content } = Astro.props;
|
|||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
|
||||
<title>{content.title}</title>
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/global.css')} />
|
||||
<style global>
|
||||
@import "../styles/global.css";
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<slot />
|
||||
|
|
|
@ -18,8 +18,10 @@ import AdminsSolid from '../components/AdminsSolid.jsx';
|
|||
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/global.css')} />
|
||||
<link rel="stylesheet" href={Astro.resolve('../styles/home.css')} />
|
||||
<style global>
|
||||
@import "../styles/global.css";
|
||||
@import "../styles/home.css";
|
||||
</style>
|
||||
|
||||
<style>
|
||||
header {
|
||||
|
|
|
@ -315,12 +315,13 @@ async function generatePath(pathname: string, opts: StaticBuildOptions, gopts: G
|
|||
|
||||
debug(logging, 'generate', `Generating: ${pathname}`);
|
||||
|
||||
const rootpath = new URL(astroConfig.buildOptions.site || 'http://localhost/').pathname;
|
||||
const result = createResult({ astroConfig, origin, params, pathname, renderers });
|
||||
result.links = new Set<SSRElement>(
|
||||
linkIds.map((href) => ({
|
||||
props: {
|
||||
rel: 'stylesheet',
|
||||
href,
|
||||
href: npath.posix.join(rootpath, href)
|
||||
},
|
||||
children: '',
|
||||
}))
|
||||
|
|
Loading…
Reference in a new issue