summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/popular-roses-ring.md5
-rw-r--r--docs/src/config.ts1
-rw-r--r--docs/src/pages/es/guides/markdown-content.astro13
-rw-r--r--docs/src/pages/es/guides/pagination.astro13
-rw-r--r--docs/src/pages/es/guides/publish-to-npm.astro13
-rw-r--r--docs/src/pages/es/guides/styling.astro13
-rw-r--r--docs/src/pages/es/reference/renderer-reference.astro13
-rw-r--r--docs/src/pages/zh-TW/themes.astro52
-rw-r--r--netlify.toml2
-rw-r--r--packages/astro/src/core/ssr/css.ts32
-rw-r--r--packages/astro/src/core/ssr/index.ts4
-rw-r--r--packages/astro/src/core/util.ts13
12 files changed, 151 insertions, 23 deletions
diff --git a/.changeset/popular-roses-ring.md b/.changeset/popular-roses-ring.md
new file mode 100644
index 000000000..b7401f61b
--- /dev/null
+++ b/.changeset/popular-roses-ring.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Bugfix: fix missing styles in build
diff --git a/docs/src/config.ts b/docs/src/config.ts
index 50132d16d..3cd88714a 100644
--- a/docs/src/config.ts
+++ b/docs/src/config.ts
@@ -135,6 +135,7 @@ export const SIDEBAR = {
{ text: '新手上路', link: 'zh-TW/getting-started' },
{ text: '快速開始', link: 'zh-TW/quick-start' },
{ text: '安裝', link: 'zh-TW/installation' },
+ { text: '佈景主題', link: 'zh-TW/themes' },
],
bg: [
{ text: 'Главни', header: true },
diff --git a/docs/src/pages/es/guides/markdown-content.astro b/docs/src/pages/es/guides/markdown-content.astro
new file mode 100644
index 000000000..562511baf
--- /dev/null
+++ b/docs/src/pages/es/guides/markdown-content.astro
@@ -0,0 +1,13 @@
+---
+import { Markdown } from 'astro/components';
+import MainLayout from '~/layouts/MainLayout.astro';
+const [content] = Astro.fetchContent('/src/pages/guides/markdown-content.md');
+---
+
+<MainLayout content="{content}">
+ <Markdown>
+ > Esta página todavía no está disponible en Español. Se muestra la versión en inglés.
+ </Markdown>
+ {content.astro.html}
+</MainLayout>
+
diff --git a/docs/src/pages/es/guides/pagination.astro b/docs/src/pages/es/guides/pagination.astro
new file mode 100644
index 000000000..65c0fe3c4
--- /dev/null
+++ b/docs/src/pages/es/guides/pagination.astro
@@ -0,0 +1,13 @@
+---
+import { Markdown } from 'astro/components';
+import MainLayout from '~/layouts/MainLayout.astro';
+const [content] = Astro.fetchContent('/src/pages/guides/pagination.md');
+---
+
+<MainLayout content="{content}">
+ <Markdown>
+ > Esta página todavía no está disponible en Español. Se muestra la versión en inglés.
+ </Markdown>
+ {content.astro.html}
+</MainLayout>
+
diff --git a/docs/src/pages/es/guides/publish-to-npm.astro b/docs/src/pages/es/guides/publish-to-npm.astro
new file mode 100644
index 000000000..a1ffac93c
--- /dev/null
+++ b/docs/src/pages/es/guides/publish-to-npm.astro
@@ -0,0 +1,13 @@
+---
+import { Markdown } from 'astro/components';
+import MainLayout from '~/layouts/MainLayout.astro';
+const [content] = Astro.fetchContent('/src/pages/guides/publish-to-npm.md');
+---
+
+<MainLayout content="{content}">
+ <Markdown>
+ > Esta página todavía no está disponible en Español. Se muestra la versión en inglés.
+ </Markdown>
+ {content.astro.html}
+</MainLayout>
+
diff --git a/docs/src/pages/es/guides/styling.astro b/docs/src/pages/es/guides/styling.astro
new file mode 100644
index 000000000..d15e6298f
--- /dev/null
+++ b/docs/src/pages/es/guides/styling.astro
@@ -0,0 +1,13 @@
+---
+import { Markdown } from 'astro/components';
+import MainLayout from '~/layouts/MainLayout.astro';
+const [content] = Astro.fetchContent('/src/pages/guides/styling.md');
+---
+
+<MainLayout content="{content}">
+ <Markdown>
+ > Esta página todavía no está disponible en Español. Se muestra la versión en inglés.
+ </Markdown>
+ {content.astro.html}
+</MainLayout>
+
diff --git a/docs/src/pages/es/reference/renderer-reference.astro b/docs/src/pages/es/reference/renderer-reference.astro
new file mode 100644
index 000000000..f3c703a60
--- /dev/null
+++ b/docs/src/pages/es/reference/renderer-reference.astro
@@ -0,0 +1,13 @@
+---
+import { Markdown } from 'astro/components';
+import MainLayout from '~/layouts/MainLayout.astro';
+const [content] = Astro.fetchContent('/src/pages/reference/renderer-reference.md');
+---
+
+<MainLayout content="{content}">
+ <Markdown>
+ > Esta página todavía no está disponible en Español. Se muestra la versión en inglés.
+ </Markdown>
+ {content.astro.html}
+</MainLayout>
+
diff --git a/docs/src/pages/zh-TW/themes.astro b/docs/src/pages/zh-TW/themes.astro
new file mode 100644
index 000000000..3c2a6cfa8
--- /dev/null
+++ b/docs/src/pages/zh-TW/themes.astro
@@ -0,0 +1,52 @@
+---
+import Layout from '../../layouts/MainLayout.astro';
+import Card from '../../components/Card.astro';
+import {Markdown} from 'astro/components';
+import themes from '../../data/themes.json';
+import components from '../../data/components.json';
+---
+<style>
+ .card-grid {
+ display: grid;
+ grid-column-gap: 15px;
+ grid-row-gap: 15px;
+ grid-auto-flow: dense;
+ grid-template-columns: repeat(auto-fit,minmax(300px,1fr))
+ }
+</style>
+<Layout content={{title: 'Themes'}} hideRightSidebar>
+ <Markdown>
+ ## 精選佈景主題
+ </Markdown>
+ <div class="card-grid">
+ {themes.featured.map((item)=>(<Card data={item} />))}
+ </div>
+ <Markdown>
+ ## 官方佈景主題
+
+ Astro 維護的文件網站、作品集⋯等官方佈景主題。
+ </Markdown>
+ <div class="card-grid">
+ {themes.official.map((item)=>(<Card data={item} />))}
+ </div>
+ <Markdown>
+ ## 社群佈景主題
+
+ 趕緊來看看社群開發的佈景主題!
+ </Markdown>
+ <div class="card-grid">
+ {themes.community.map((item)=>(<Card data={item} />))}
+ </div>
+ <Markdown>
+ ## 精選套件
+
+ 我們的套件生態持續成長!所有精選社群套件都可以在 [npm](https://www.npmjs.com/search?q=keywords%3Aastro-component) 發掘。
+ </Markdown>
+ <div class="card-grid">
+ {components.community.map((item)=>(<Card data={item} />))}
+ </div>
+ <Markdown>
+ > 想要讓自己的作品成為精選嗎?[在 Discord 分享!](https://astro.build/chat)
+ 我們常在 `#showcase` 頻道取材,把深受喜愛的在這裡發布。
+ </Markdown>
+</Layout>
diff --git a/netlify.toml b/netlify.toml
index 402f958ec..fd6fa2029 100644
--- a/netlify.toml
+++ b/netlify.toml
@@ -1,2 +1,2 @@
[build]
- ignore = "git diff --quiet $COMMIT_REF $CACHED_COMMIT_REF -- docs/ www/"
+ ignore = "git diff --quiet $COMMIT_REF $CACHED_COMMIT_REF -- packages/astro/src docs/ www/"
diff --git a/packages/astro/src/core/ssr/css.ts b/packages/astro/src/core/ssr/css.ts
index 0f2ffb00a..2a2fa24a7 100644
--- a/packages/astro/src/core/ssr/css.ts
+++ b/packages/astro/src/core/ssr/css.ts
@@ -1,34 +1,40 @@
import type vite from '../vite';
import path from 'path';
-import { viteifyURL } from '../util.js';
+import { viteID } from '../util.js';
// https://vitejs.dev/guide/features.html#css-pre-processors
export const STYLE_EXTENSIONS = new Set(['.css', '.pcss', '.postcss', '.scss', '.sass', '.styl', '.stylus', '.less']);
-/** find unloaded styles */
+/**
+ * getStylesForURL
+ * Given a filePath URL, crawl Vite’s module graph to find style files
+ */
export function getStylesForURL(filePath: URL, viteServer: vite.ViteDevServer): Set<string> {
const css = new Set<string>();
- const rootID = viteifyURL(filePath);
// recursively crawl module graph to get all style files imported by parent id
- function crawlCSS(entryModule: string, scanned = new Set<string>()) {
- const moduleName = viteServer.moduleGraph.urlToModuleMap.get(entryModule);
+ function crawlCSS(id: string, scanned = new Set<string>()) {
+ // note: use .idToModuleMap() for lookups (.urlToModuleMap() may produce different
+ // URLs for modules depending on conditions, making resolution difficult)
+ const moduleName = viteServer.moduleGraph.idToModuleMap.get(id);
if (!moduleName || !moduleName.id) return;
- // mark the entrypoint as scanned to avoid an infinite loop
- scanned.add(moduleName.url);
+
+ scanned.add(moduleName.id);
+
+ // scan importedModules
for (const importedModule of moduleName.importedModules) {
- if (!importedModule.url || scanned.has(importedModule.url)) continue;
+ if (!importedModule.id || scanned.has(importedModule.id)) continue;
const ext = path.extname(importedModule.url.toLowerCase());
if (STYLE_EXTENSIONS.has(ext)) {
- css.add(importedModule.url); // if style file, add to list
- } else {
- crawlCSS(importedModule.url, scanned); // otherwise, crawl file to see if it imports any CSS
+ css.add(importedModule.url); // note: return `url`s for HTML (not .id, which will break Windows)
}
- scanned.add(importedModule.url);
+ crawlCSS(importedModule.id, scanned);
+ scanned.add(importedModule.id);
}
}
- crawlCSS(rootID);
+
+ crawlCSS(viteID(filePath));
return css;
}
diff --git a/packages/astro/src/core/ssr/index.ts b/packages/astro/src/core/ssr/index.ts
index 499039a56..4b979a182 100644
--- a/packages/astro/src/core/ssr/index.ts
+++ b/packages/astro/src/core/ssr/index.ts
@@ -23,7 +23,7 @@ import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { renderPage, renderSlot } from '../../runtime/server/index.js';
-import { canonicalURL as getCanonicalURL, codeFrame, resolveDependency, viteifyURL } from '../util.js';
+import { canonicalURL as getCanonicalURL, codeFrame, resolveDependency } from '../util.js';
import { getStylesForURL } from './css.js';
import { injectTags } from './html.js';
import { generatePaginateFunction } from './paginate.js';
@@ -133,7 +133,7 @@ export async function preload({ astroConfig, filePath, viteServer }: SSROptions)
// Important: This needs to happen first, in case a renderer provides polyfills.
const renderers = await resolveRenderers(viteServer, astroConfig);
// Load the module from the Vite SSR Runtime.
- const mod = (await viteServer.ssrLoadModule(viteifyURL(filePath))) as ComponentInstance;
+ const mod = (await viteServer.ssrLoadModule(fileURLToPath(filePath))) as ComponentInstance;
return [renderers, mod];
}
diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts
index df93938bc..51ba0db8a 100644
--- a/packages/astro/src/core/util.ts
+++ b/packages/astro/src/core/util.ts
@@ -74,12 +74,11 @@ export function resolveDependency(dep: string, astroConfig: AstroConfig) {
}
/**
- * Vite-ify URL
- * Given a file URL, return an ID that matches Vite’s module graph. Needed for resolution and stack trace fixing.
- * Must match the following format:
- * Linux/Mac: /@fs/Users/astro/code/my-project/src/pages/index.astro
- * Windows: /@fs/C:/Users/astro/code/my-project/src/pages/index.astro
+ * Convert file URL to ID for viteServer.moduleGraph.idToModuleMap.get(:viteID)
+ * Format:
+ * Linux/Mac: /Users/astro/code/my-project/src/pages/index.astro
+ * Windows: C:/Users/astro/code/my-project/src/pages/index.astro
*/
-export function viteifyURL(filePath: URL): string {
- return `/@fs${slash(fileURLToPath(filePath)).replace(/^\/?/, '/')}`;
+export function viteID(filePath: URL): string {
+ return slash(fileURLToPath(filePath));
}