Skip to content

Commit

Permalink
Merge branch 'main' into fix-solid-library
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Oct 12, 2022
2 parents 060ea54 + 5cab045 commit d8994c5
Show file tree
Hide file tree
Showing 18 changed files with 678 additions and 493 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Examples astro check

on:
push:
branches:
- main
pull_request:
paths:
- 'examples/**'
- '.github/workflows/check.yml'
- 'scripts/smoke/check.js'
- 'packages/astro/src/@types/astro.ts'

env:
ASTRO_TELEMETRY_DISABLED: true
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
FORCE_COLOR: true

jobs:
check:
name: astro check
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Setup PNPM
uses: pnpm/action-setup@v2.2.1

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm run build

- name: Status
run: git status

- name: astro check
run: pnpm run test:check-examples
7 changes: 6 additions & 1 deletion examples/framework-lit/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import { MyCounter } from '../components/my-counter.js';
<h1>Test app</h1>
<MyCounter client:load />
<Lorem />
<CalcAdd num={33} />

{/**
* Our VS Code extension does not currently properly typecheck attributes on Lit components
* As such, the following code will result in a TypeScript error inside the editor, nonetheless, it works in Astro!
* @ts-expect-error */}
<CalcAdd num={0} />
</body>
</html>
8 changes: 5 additions & 3 deletions examples/non-html-pages/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
// can fetch them directly in the browser.
const response = await fetch(`/about.json`);
const data = await response.json();
document.getElementById(
'result'
).innerHTML = `Load complete!<br/>Built with: <a href="${data.url}">${data.name}!</a>`;
const resultHeader = document.getElementById('result');

if (resultHeader) {
resultHeader.innerHTML = `Load complete!<br/>Built with: <a href="${data.url}">${data.name}!</a>`;
}
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions examples/portfolio/src/components/PortfolioPreview.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---
import type { MarkdownInstance } from 'astro';
import type { Project } from '../types';
interface Props {
project: MarkdownInstance<Project>;
}
const { frontmatter, url } = Astro.props.project;
---

Expand Down
7 changes: 6 additions & 1 deletion examples/portfolio/src/layouts/project.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
import MainHead from '../components/MainHead.astro';
import Footer from '../components/Footer.astro';
import Nav from '../components/Nav.astro';
import type { Project } from '../types';
interface Props {
content: Project;
}
const { content } = Astro.props;
---

<html lang={content.lang || 'en'}>
<html lang="en">
<head>
<MainHead title={content.title} description={content.description} />
<style>
Expand Down
5 changes: 3 additions & 2 deletions examples/portfolio/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import MainHead from '../components/MainHead.astro';
import Nav from '../components/Nav.astro';
import Footer from '../components/Footer.astro';
import PortfolioPreview from '../components/PortfolioPreview.astro';
import type { Project } from '../types';
// Data Fetching: List all Markdown posts in the repo.
const projects = await Astro.glob('./project/**/*.md');
const featuredProject = projects[0];
const projects = await Astro.glob<Project>('./project/**/*.md');
const featuredProject = projects[0]!;
// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down
3 changes: 2 additions & 1 deletion examples/portfolio/src/pages/projects.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import MainHead from '../components/MainHead.astro';
import Footer from '../components/Footer.astro';
import Nav from '../components/Nav.astro';
import PortfolioPreview from '../components/PortfolioPreview.astro';
import type { Project } from '../types';
const projects = (await Astro.glob('./project/**/*.md'))
const projects = (await Astro.glob<Project>('./project/**/*.md'))
.filter(({ frontmatter }) => !!frontmatter.publishDate)
.sort(
(a, b) =>
Expand Down
8 changes: 8 additions & 0 deletions examples/portfolio/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface Project {
title: string;
client: string;
description: string;
publishDate: string;
tags: string[];
img: string;
}
2 changes: 1 addition & 1 deletion examples/ssr/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface Product {
export interface Product {
id: number;
name: string;
price: number;
Expand Down
6 changes: 6 additions & 0 deletions examples/ssr/src/components/ProductListing.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
import type { Product } from '../api';
interface Props {
products: Product[];
}
const { products } = Astro.props;
---

Expand Down
4 changes: 4 additions & 0 deletions examples/ssr/src/components/TextDecorationSkip.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
interface Props {
text: string;
}
const { text } = Astro.props;
const words = text.split(' ');
const last = words.length - 1;
Expand Down
5 changes: 1 addition & 4 deletions examples/ssr/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ const products = await getProducts(Astro.request);
.product-listing-title {
text-align: center;
}

.product-listing {
}
</style>
</head>
<body>
<Header />

<Container tag="main">
<ProductListing products={products} class="product-listing">
<ProductListing products={products}>
<h2 class="product-listing-title" slot="title">Product Listing</h2>
</ProductListing>
</Container>
Expand Down
3 changes: 2 additions & 1 deletion examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.4.7",
"@astrojs/tailwind": "^2.0.2",
"@types/canvas-confetti": "^1.4.3",
"astro": "^1.4.7",
"autoprefixer": "^10.4.7",
"canvas-confetti": "^1.5.1",
"postcss": "^8.4.14",
Expand Down
6 changes: 5 additions & 1 deletion examples/with-tailwindcss/src/components/Button.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@

<script>
import confetti from 'canvas-confetti';
document.body.querySelector('button').addEventListener('click', () => confetti());
const button = document.body.querySelector('button');

if (button) {
button.addEventListener('click', () => confetti());
}
</script>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"test": "turbo run test --output-logs=new-only --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"",
"test:match": "cd packages/astro && pnpm run test:match",
"test:smoke": "turbo run build --filter=\"@example/*\" --filter=\"astro.build\" --filter=\"docs\" --output-logs=new-only --concurrency=1",
"test:check-examples": "node ./scripts/smoke/check.js",
"test:vite-ci": "turbo run test --filter=astro --output-logs=new-only --no-deps --concurrency=1",
"test:e2e": "cd packages/astro && pnpm playwright install && pnpm run test:e2e",
"test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match",
Expand Down
Loading

0 comments on commit d8994c5

Please sign in to comment.