Skip to content

Commit 7941f5a

Browse files
authored
[examples] Update Astro template for 1.0. (vercel#8357)
To prepare for [Astro 1.0](https://github.com/withastro/astro/releases/tag/astro%401.0.0-rc.1), this PR updates the template (it has [been deployed](https://astro-template.vercel.app/)).
1 parent 5b931af commit 7941f5a

File tree

11 files changed

+984
-1321
lines changed

11 files changed

+984
-1321
lines changed

examples/astro/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ pnpm-debug.log*
1818

1919
# macOS-specific files
2020
.DS_Store
21+
.vercel

examples/astro/.vercelignore

-1
This file was deleted.

examples/astro/README.md

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
# Welcome to [Astro](https://astro.build)
1+
# Astro
22

3-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/starter)
3+
This directory is a brief example of an [Astro](https://astro.build/) site that can be deployed to Vercel with zero configuration.
44

5-
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
5+
## Deploy Your Own
66

7-
## 🚀 Project Structure
7+
Deploy your own Astro project with Vercel.
8+
9+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/astro&template=astro)
10+
11+
_Live Example: https://astro-template.vercel.app_
12+
13+
## Project Structure
814

915
Inside of your Astro project, you'll see the following folders and files:
1016

@@ -26,17 +32,15 @@ There's nothing special about `src/components/`, but that's where we like to put
2632

2733
Any static assets, like images, can be placed in the `public/` directory.
2834

29-
## 🧞 Commands
35+
## Commands
3036

3137
All commands are run from the root of the project, from a terminal:
3238

33-
| Command | Action |
34-
| :---------------- | :------------------------------------------- |
35-
| `npm install` | Installs dependencies |
36-
| `npm run dev` | Starts local dev server at `localhost:3000` |
37-
| `npm run build` | Build your production site to `./dist/` |
38-
| `npm run preview` | Preview your build locally, before deploying |
39-
40-
## 👀 Want to learn more?
41-
42-
Feel free to check [our documentation](https://github.com/withastro/astro) or jump into our [Discord server](https://astro.build/chat).
39+
| Command | Action |
40+
| :--------------------- | :------------------------------------------------- |
41+
| `npm install` | Installs dependencies |
42+
| `npm run dev` | Starts local dev server at `localhost:3000` |
43+
| `npm run build` | Build your production site to `./dist/` |
44+
| `npm run preview` | Preview your build locally, before deploying |
45+
| `npm run astro ...` | Run CLI commands like `astro add`, `astro preview` |
46+
| `npm run astro --help` | Get help using the Astro CLI |

examples/astro/package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
2-
"name": "@example/basics",
3-
"version": "0.0.1",
42
"private": true,
53
"scripts": {
64
"dev": "astro dev",
75
"start": "astro dev",
86
"build": "astro build",
9-
"preview": "astro preview"
7+
"preview": "astro preview",
8+
"astro": "astro"
109
},
1110
"devDependencies": {
12-
"astro": "^1.0.0-beta.20"
11+
"astro": "^1.0.0-rc.8"
1312
}
1413
}
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
export interface Props {
3+
title: string;
4+
body: string;
5+
href: string;
6+
}
7+
8+
const { href, title, body } = Astro.props as Props;
9+
---
10+
11+
<li class="link-card">
12+
<a href={href}>
13+
<h2>
14+
{title}
15+
<span>&rarr;</span>
16+
</h2>
17+
<p>
18+
{body}
19+
</p>
20+
</a>
21+
</li>
22+
<style>
23+
:root {
24+
--link-gradient: linear-gradient(45deg, #4f39fa, #da62c4 30%, var(--color-border) 60%);
25+
}
26+
27+
.link-card {
28+
list-style: none;
29+
display: flex;
30+
padding: 0.15rem;
31+
background-image: var(--link-gradient);
32+
background-size: 400%;
33+
border-radius: 0.5rem;
34+
background-position: 100%;
35+
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
36+
}
37+
38+
.link-card > a {
39+
width: 100%;
40+
text-decoration: none;
41+
line-height: 1.4;
42+
padding: 1em 1.3em;
43+
border-radius: 0.35rem;
44+
color: var(--text-color);
45+
background-color: white;
46+
opacity: 0.8;
47+
}
48+
49+
h2 {
50+
margin: 0;
51+
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
52+
}
53+
54+
p {
55+
margin-top: 0.75rem;
56+
margin-bottom: 0;
57+
}
58+
59+
h2 span {
60+
display: inline-block;
61+
transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
62+
}
63+
64+
.link-card:is(:hover, :focus-within) {
65+
background-position: 0;
66+
}
67+
68+
.link-card:is(:hover, :focus-within) h2 {
69+
color: #4f39fa;
70+
}
71+
72+
.link-card:is(:hover, :focus-within) h2 span {
73+
will-change: transform;
74+
transform: translateX(2px);
75+
}
76+
</style>

examples/astro/src/components/Layout.astro

-55
This file was deleted.

examples/astro/src/env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="astro/client" />
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
export interface Props {
3+
title: string;
4+
}
5+
6+
const { title } = Astro.props as Props;
7+
---
8+
9+
<!DOCTYPE html>
10+
<html lang="en">
11+
<head>
12+
<meta charset="UTF-8" />
13+
<meta name="viewport" content="width=device-width" />
14+
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
15+
<meta name="generator" content={Astro.generator} />
16+
<title>{title}</title>
17+
</head>
18+
<body>
19+
<slot />
20+
</body>
21+
</html>
22+
<style>
23+
:root {
24+
--font-size-base: clamp(1rem, 0.34vw + 0.91rem, 1.19rem);
25+
--font-size-lg: clamp(1.2rem, 0.7vw + 1.2rem, 1.5rem);
26+
--font-size-xl: clamp(2.44rem, 2.38vw + 1.85rem, 3.75rem);
27+
28+
--color-text: hsl(12, 5%, 4%);
29+
--color-bg: hsl(10, 21%, 95%);
30+
--color-border: hsl(17, 24%, 90%);
31+
}
32+
33+
html {
34+
font-family: system-ui, sans-serif;
35+
font-size: var(--font-size-base);
36+
color: var(--color-text);
37+
background-color: var(--color-bg);
38+
}
39+
40+
body {
41+
margin: 0;
42+
}
43+
44+
:global(h1) {
45+
font-size: var(--font-size-xl);
46+
}
47+
48+
:global(h2) {
49+
font-size: var(--font-size-lg);
50+
}
51+
52+
:global(code) {
53+
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
54+
Bitstream Vera Sans Mono, Courier New, monospace;
55+
}
56+
</style>

0 commit comments

Comments
 (0)