Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
docs: astro streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
jayair committed Sep 23, 2024
1 parent a95974a commit c1a9ec9
Show file tree
Hide file tree
Showing 22 changed files with 475 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/aws-astro-stream/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# build output
dist/

# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# jetbrains setting folder
.idea/

# sst
.sst
4 changes: 4 additions & 0 deletions examples/aws-astro-stream/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions examples/aws-astro-stream/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
54 changes: 54 additions & 0 deletions examples/aws-astro-stream/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Astro Starter Kit: Basics

```sh
npm create astro@latest -- --template basics
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
![just-the-basics](https://github.com/withastro/astro/assets/2244813/a0a5533c-a856-4198-8470-2d67b1d7c554)

## 🚀 Project Structure

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

```text
/
├── public/
│ └── favicon.svg
├── src/
│ ├── components/
│ │ └── Card.astro
│ ├── layouts/
│ │ └── Layout.astro
│ └── pages/
│ └── index.astro
└── package.json
```

Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.

There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.

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

## 🧞 Commands

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

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
11 changes: 11 additions & 0 deletions examples/aws-astro-stream/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check
import aws from "astro-sst";
import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
output: "server",
adapter: aws({
responseMode: "stream",
}),
});
19 changes: 19 additions & 0 deletions examples/aws-astro-stream/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "aws-astro-stream",
"type": "module",
"version": "0.0.1",
"scripts": {
"astro": "astro",
"build": "astro check && astro build",
"dev": "astro dev",
"preview": "astro preview",
"start": "astro dev"
},
"dependencies": {
"@astrojs/check": "^0.9.3",
"astro": "^4.15.9",
"astro-sst": "2.43.5",
"sst": "latest",
"typescript": "^5.6.2"
}
}
9 changes: 9 additions & 0 deletions examples/aws-astro-stream/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/aws-astro-stream/public/mr-krabs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/aws-astro-stream/public/patrick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/aws-astro-stream/public/sandy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/aws-astro-stream/public/spongebob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/aws-astro-stream/public/squidward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions examples/aws-astro-stream/src/components/Bio.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
import type { Character } from "./character";
const spongebob: Character = {
name: "SpongeBob SquarePants",
description: "SpongeBob SquarePants is the main character of the popular animated TV series. He's a cheerful sea sponge who lives in a pineapple house in the underwater city of Bikini Bottom. SpongeBob works as a fry cook at the Krusty Krab and loves jellyfishing with his best friend Patrick Star.",
image: "spongebob.png",
};
---
<section class="section">
<h1>{spongebob.name}</h1>
<div class="content">
<div class="text">
<p>{spongebob.description}</p>
</div>
<img src={spongebob.image} alt={spongebob.name} />
</div>
</section>

<style>
.section {
background-color: #fff;
padding: 20px;
margin-bottom: 20px;
border-radius: 10px;
}
.content {
display: flex;
align-items: center;
}
.text {
flex: 1;
padding-right: 20px;
}
</style>
43 changes: 43 additions & 0 deletions examples/aws-astro-stream/src/components/Friends.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
import type { Character } from "./character";
const friends: Character[] = await new Promise((resolve) => setTimeout(() => {
setTimeout(() => {
resolve(
[
{ name: "Patrick Star", image: "patrick.png" },
{ name: "Sandy Cheeks", image: "sandy.png" },
{ name: "Squidward Tentacles", image: "squidward.png" },
{ name: "Mr. Krabs", image: "mr-krabs.png" },
]
);
}, 3000);
}));
---
<div class="grid">
{friends.map((friend) => (
<div class="card">
<img class="img" src={friend.image} alt={friend.name} />
<p>{friend.name}</p>
</div>
))}
</div>

<style>
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 20px;
}
.card {
background-color: #fff;
padding: 10px;
border-radius: 5px;
text-align: center;
}
.img {
max-width: 100%;
height: auto;
border-radius: 5px;
}
</style>
5 changes: 5 additions & 0 deletions examples/aws-astro-stream/src/components/character.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface Character {
name: string;
image: string;
description?: string;
}
1 change: 1 addition & 0 deletions examples/aws-astro-stream/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../.astro/types.d.ts" />
39 changes: 39 additions & 0 deletions examples/aws-astro-stream/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
interface Props {
title: string;
}
const { title } = Astro.props;
---

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
</head>
<body>
<div class="container">
<slot />
</div>
</body>
</html>
<style is:global>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f8ff;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
</style>
73 changes: 73 additions & 0 deletions examples/aws-astro-stream/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
import Layout from '../layouts/Layout.astro';
import Bio from '../components/Bio.astro';
import Friends from '../components/Friends.astro';
---

<Layout title="Welcome to Astro">
<Bio />

<section>
<h2>Friends from Bikini Bottom</h2>
<Friends />
</section>
</Layout>

<style>
main {
margin: auto;
padding: 1rem;
width: 800px;
max-width: calc(100% - 2rem);
color: white;
font-size: 20px;
line-height: 1.6;
}
.astro-a {
position: absolute;
top: -32px;
left: 50%;
transform: translatex(-50%);
width: 220px;
height: auto;
z-index: -1;
}
h1 {
font-size: 4rem;
font-weight: 700;
line-height: 1;
text-align: center;
margin-bottom: 1em;
}
.text-gradient {
background-image: var(--accent-gradient);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 400%;
background-position: 0%;
}
.instructions {
margin-bottom: 2rem;
border: 1px solid rgba(var(--accent-light), 25%);
background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%));
padding: 1.5rem;
border-radius: 8px;
}
.instructions code {
font-size: 0.8em;
font-weight: bold;
background: rgba(var(--accent-light), 12%);
color: rgb(var(--accent-light));
border-radius: 4px;
padding: 0.3em 0.4em;
}
.instructions strong {
color: rgb(var(--accent-light));
}
.link-card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
gap: 2rem;
padding: 0;
}
</style>
9 changes: 9 additions & 0 deletions examples/aws-astro-stream/sst-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* This file is auto-generated by SST. Do not edit. */
/* tslint:disable */
/* eslint-disable */
import "sst"
export {}
declare module "sst" {
export interface Resource {
}
}
Loading

0 comments on commit c1a9ec9

Please sign in to comment.