Skip to content

Commit d8994c5

Browse files
committed
Merge branch 'main' into fix-solid-library
2 parents 060ea54 + 5cab045 commit d8994c5

File tree

18 files changed

+678
-493
lines changed

18 files changed

+678
-493
lines changed

.github/workflows/check.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Examples astro check
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
paths:
9+
- 'examples/**'
10+
- '.github/workflows/check.yml'
11+
- 'scripts/smoke/check.js'
12+
- 'packages/astro/src/@types/astro.ts'
13+
14+
env:
15+
ASTRO_TELEMETRY_DISABLED: true
16+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
17+
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
18+
FORCE_COLOR: true
19+
20+
jobs:
21+
check:
22+
name: astro check
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Check out repository
26+
uses: actions/checkout@v3
27+
28+
- name: Setup PNPM
29+
uses: pnpm/[email protected]
30+
31+
- name: Setup Node
32+
uses: actions/setup-node@v3
33+
with:
34+
node-version: 16
35+
cache: 'pnpm'
36+
37+
- name: Install dependencies
38+
run: pnpm install
39+
40+
- name: Build
41+
run: pnpm run build
42+
43+
- name: Status
44+
run: git status
45+
46+
- name: astro check
47+
run: pnpm run test:check-examples

examples/framework-lit/src/pages/index.astro

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ import { MyCounter } from '../components/my-counter.js';
1919
<h1>Test app</h1>
2020
<MyCounter client:load />
2121
<Lorem />
22-
<CalcAdd num={33} />
22+
23+
{/**
24+
* Our VS Code extension does not currently properly typecheck attributes on Lit components
25+
* As such, the following code will result in a TypeScript error inside the editor, nonetheless, it works in Astro!
26+
* @ts-expect-error */}
27+
<CalcAdd num={0} />
2328
</body>
2429
</html>

examples/non-html-pages/src/pages/index.astro

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
// can fetch them directly in the browser.
1313
const response = await fetch(`/about.json`);
1414
const data = await response.json();
15-
document.getElementById(
16-
'result'
17-
).innerHTML = `Load complete!<br/>Built with: <a href="${data.url}">${data.name}!</a>`;
15+
const resultHeader = document.getElementById('result');
16+
17+
if (resultHeader) {
18+
resultHeader.innerHTML = `Load complete!<br/>Built with: <a href="${data.url}">${data.name}!</a>`;
19+
}
1820
</script>
1921
</body>
2022
</html>

examples/portfolio/src/components/PortfolioPreview.astro

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
---
2+
import type { MarkdownInstance } from 'astro';
3+
import type { Project } from '../types';
4+
5+
interface Props {
6+
project: MarkdownInstance<Project>;
7+
}
8+
29
const { frontmatter, url } = Astro.props.project;
310
---
411

examples/portfolio/src/layouts/project.astro

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
import MainHead from '../components/MainHead.astro';
33
import Footer from '../components/Footer.astro';
44
import Nav from '../components/Nav.astro';
5+
import type { Project } from '../types';
6+
7+
interface Props {
8+
content: Project;
9+
}
510
611
const { content } = Astro.props;
712
---
813

9-
<html lang={content.lang || 'en'}>
14+
<html lang="en">
1015
<head>
1116
<MainHead title={content.title} description={content.description} />
1217
<style>

examples/portfolio/src/pages/index.astro

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import MainHead from '../components/MainHead.astro';
44
import Nav from '../components/Nav.astro';
55
import Footer from '../components/Footer.astro';
66
import PortfolioPreview from '../components/PortfolioPreview.astro';
7+
import type { Project } from '../types';
78
89
// Data Fetching: List all Markdown posts in the repo.
9-
const projects = await Astro.glob('./project/**/*.md');
10-
const featuredProject = projects[0];
10+
const projects = await Astro.glob<Project>('./project/**/*.md');
11+
const featuredProject = projects[0]!;
1112
1213
// Full Astro Component Syntax:
1314
// https://docs.astro.build/core-concepts/astro-components/

examples/portfolio/src/pages/projects.astro

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import MainHead from '../components/MainHead.astro';
33
import Footer from '../components/Footer.astro';
44
import Nav from '../components/Nav.astro';
55
import PortfolioPreview from '../components/PortfolioPreview.astro';
6+
import type { Project } from '../types';
67
7-
const projects = (await Astro.glob('./project/**/*.md'))
8+
const projects = (await Astro.glob<Project>('./project/**/*.md'))
89
.filter(({ frontmatter }) => !!frontmatter.publishDate)
910
.sort(
1011
(a, b) =>

examples/portfolio/src/types.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface Project {
2+
title: string;
3+
client: string;
4+
description: string;
5+
publishDate: string;
6+
tags: string[];
7+
img: string;
8+
}

examples/ssr/src/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface Product {
1+
export interface Product {
22
id: number;
33
name: string;
44
price: number;

examples/ssr/src/components/ProductListing.astro

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---
2+
import type { Product } from '../api';
3+
4+
interface Props {
5+
products: Product[];
6+
}
7+
28
const { products } = Astro.props;
39
---
410

examples/ssr/src/components/TextDecorationSkip.astro

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
---
2+
interface Props {
3+
text: string;
4+
}
5+
26
const { text } = Astro.props;
37
const words = text.split(' ');
48
const last = words.length - 1;

examples/ssr/src/pages/index.astro

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@ const products = await getProducts(Astro.request);
1919
.product-listing-title {
2020
text-align: center;
2121
}
22-
23-
.product-listing {
24-
}
2522
</style>
2623
</head>
2724
<body>
2825
<Header />
2926

3027
<Container tag="main">
31-
<ProductListing products={products} class="product-listing">
28+
<ProductListing products={products}>
3229
<h2 class="product-listing-title" slot="title">Product Listing</h2>
3330
</ProductListing>
3431
</Container>

examples/with-tailwindcss/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
"astro": "astro"
1212
},
1313
"dependencies": {
14-
"astro": "^1.4.7",
1514
"@astrojs/tailwind": "^2.0.2",
15+
"@types/canvas-confetti": "^1.4.3",
16+
"astro": "^1.4.7",
1617
"autoprefixer": "^10.4.7",
1718
"canvas-confetti": "^1.5.1",
1819
"postcss": "^8.4.14",

examples/with-tailwindcss/src/components/Button.astro

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@
1111

1212
<script>
1313
import confetti from 'canvas-confetti';
14-
document.body.querySelector('button').addEventListener('click', () => confetti());
14+
const button = document.body.querySelector('button');
15+
16+
if (button) {
17+
button.addEventListener('click', () => confetti());
18+
}
1519
</script>

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"test": "turbo run test --output-logs=new-only --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"",
2020
"test:match": "cd packages/astro && pnpm run test:match",
2121
"test:smoke": "turbo run build --filter=\"@example/*\" --filter=\"astro.build\" --filter=\"docs\" --output-logs=new-only --concurrency=1",
22+
"test:check-examples": "node ./scripts/smoke/check.js",
2223
"test:vite-ci": "turbo run test --filter=astro --output-logs=new-only --no-deps --concurrency=1",
2324
"test:e2e": "cd packages/astro && pnpm playwright install && pnpm run test:e2e",
2425
"test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match",

0 commit comments

Comments
 (0)