Skip to content

Commit 62e8775

Browse files
authored
Merge pull request #727 from arthelokyo/modernize/astro7-refinement
Astro7 refinement
2 parents cab8521 + ae05564 commit 62e8775

27 files changed

Lines changed: 1592 additions & 1494 deletions

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

AGENTS.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## Project Overview
44

5-
AstroWind is a free, open-source website template built with **Astro v6** and **Tailwind CSS v4**. It generates a fully static site optimized for performance, SEO, and accessibility.
5+
AstroWind is a free, open-source website template built with **Astro v7** and **Tailwind CSS v4**. It generates a fully static site optimized for performance, SEO, and accessibility.
66

7-
**Stack:** Astro v6 | Tailwind CSS v4 | TypeScript 5.9 | MDX | Sharp
7+
**Stack:** Astro v7 | Tailwind CSS v4 | TypeScript 5.9 | MDX | Sharp
88

99
## Quick Reference
1010

@@ -27,11 +27,11 @@ src/
2727
assets/styles/tailwind.css # Tailwind v4 config (themes, utilities, plugins)
2828
components/
2929
common/ # Shared: Image, Metadata, Analytics, ToggleTheme
30-
ui/ # Primitives: Button, Headline, WidgetWrapper, ItemGrid
30+
ui/ # Primitives: Button, Form, Headline, Timeline, WidgetWrapper
3131
widgets/ # Page sections: Hero, Features, Pricing, Header, Footer
3232
blog/ # Blog: SinglePost, List, Pagination, Tags
3333
CustomStyles.astro # CSS variables for colors and fonts
34-
content.config.ts # Content Collections schema (Astro v6 location)
34+
content.config.ts # Content Collections schema (Astro 5+ location)
3535
data/post/ # Blog posts (.md, .mdx)
3636
layouts/ # Layout.astro, PageLayout.astro, MarkdownLayout.astro
3737
pages/ # File-based routing
@@ -75,7 +75,7 @@ Components use `twMerge` from `tailwind-merge` v3 for conditional class composit
7575

7676
## Content Collections
7777

78-
Defined in `src/content.config.ts` using the Astro v6 Content Layer API with `glob()` loader. Posts are in `src/data/post/` as `.md` or `.mdx` files.
78+
Defined in `src/content.config.ts` using Astro's Content Layer API with `glob()` loader. Posts are in `src/data/post/` as `.md` or `.mdx` files.
7979

8080
Post frontmatter: `title` (required), `publishDate`, `updateDate`, `draft`, `excerpt`, `image`, `category`, `tags`, `author`, `metadata`.
8181

@@ -97,6 +97,18 @@ Post frontmatter: `title` (required), `publishDate`, `updateDate`, `draft`, `exc
9797

9898
Hero images use `loading="eager"` and `fetchpriority="high"`.
9999

100+
## Fonts
101+
102+
Fonts are handled by Astro's native **Fonts API**, configured in `astro.config.ts` under the `fonts` key (provider, family, `cssVariable`) and injected via the `<Font />` component in `src/layouts/Layout.astro`. Astro self-hosts, subsets, preloads, and generates metric-adjusted fallbacks. To change the typeface, edit the `fonts` entry and point `--aw-font-*` in `CustomStyles.astro` at the new `cssVariable`.
103+
104+
## Third-party Scripts (Partytown)
105+
106+
`@astrojs/partytown` is wired as an **opt-in** in `astro.config.ts`, gated behind `const hasExternalScripts = false`. Set it to `true` to offload third-party scripts (e.g. Google Analytics via `analytics.vendors.googleAnalytics.partytown`) to a web worker. It is disabled by default so the base template ships no external scripts.
107+
108+
## Content Security Policy
109+
110+
Astro's native CSP is intentionally **not** enabled in this version: it is incompatible with `<ClientRouter />` view transitions (shipped on by default) and would break the arbitrary third-party scripts a template user typically adds. CSP is deferred to AstroWind v2, where the component model (and optional SSR) make it clean and opt-in.
111+
100112
## Verification Checklist
101113

102114
After changes, always verify:

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
-**Image Optimization** (using new **Astro Assets** and **Unpic** for Universal image CDN).
1414
- ✅ Generation of **project sitemap** based on your routes.
1515
-**Open Graph tags** for social media sharing.
16-
-**Analytics** built-in Google Analytics, and Splitbee integration.
16+
-**Analytics** built-in Google Analytics integration.
1717

1818
<br>
1919

@@ -124,7 +124,7 @@ Inside **AstroWind** template, you'll see the following folders and files:
124124
│ │ └── ...
125125
│ ├── utils/
126126
│ ├── config.yaml
127-
│ └── navigation.js
127+
│ └── navigation.ts
128128
├── package.json
129129
├── astro.config.ts
130130
└── ...
@@ -280,14 +280,6 @@ Clone this repository on your own GitHub account and deploy to PandaStack:
280280

281281
<br>
282282

283-
## Frequently Asked Questions
284-
285-
- Why?
286-
-
287-
-
288-
289-
<br>
290-
291283
## Contributing
292284

293285
If you have any ideas, suggestions or find any bugs, feel free to open a discussion, an issue or create a pull request.

astro.config.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path';
22
import { fileURLToPath } from 'url';
33

4-
import { defineConfig } from 'astro/config';
4+
import { defineConfig, fontProviders } from 'astro/config';
55

66
import { unified } from '@astrojs/markdown-remark';
77

@@ -26,6 +26,28 @@ const whenExternalScripts = (items: (() => AstroIntegration) | (() => AstroInteg
2626
export default defineConfig({
2727
output: 'static',
2828

29+
// Prefetch links as they enter the viewport for snappier navigations
30+
// (works together with <ClientRouter />, which enables prefetch by default).
31+
prefetch: {
32+
prefetchAll: true,
33+
defaultStrategy: 'viewport',
34+
},
35+
36+
// Native Fonts API: self-hosts + subsets + preloads Inter and generates
37+
// metric-adjusted fallbacks. Injected via <Font /> in Layout.astro and
38+
// consumed through the `--font-inter` CSS variable in CustomStyles.astro.
39+
fonts: [
40+
{
41+
provider: fontProviders.fontsource(),
42+
name: 'Inter',
43+
cssVariable: '--font-inter',
44+
weights: ['100 900'],
45+
styles: ['normal'],
46+
subsets: ['latin'],
47+
fallbacks: ['sans-serif'],
48+
},
49+
],
50+
2951
integrations: [
3052
sitemap(),
3153
mdx(),
@@ -86,6 +108,11 @@ export default defineConfig({
86108
// native <Image /> (i.e. providers Unpic can't detect, like Pixabay).
87109
// Listed entries are authorized to be processed by Sharp.
88110
domains: ['cdn.pixabay.com'],
111+
112+
// Emit responsive styles for the native <Image layout=…> used by
113+
// src/components/common/Image.astro (local images). Utility classes on
114+
// each usage still win, since these styles use low-specificity selectors.
115+
responsiveStyles: true,
89116
},
90117

91118
markdown: {

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import astroEslintParser from 'astro-eslint-parser';
1+
import * as astroEslintParser from 'astro-eslint-parser';
22
import eslintPluginAstro from 'eslint-plugin-astro';
33
import globals from 'globals';
44
import js from '@eslint/js';

0 commit comments

Comments
 (0)