update the blog example (#565)

This commit is contained in:
Fred K. Schott 2021-06-28 15:29:16 -07:00 committed by GitHub
parent 7063c04dec
commit 5591d4eb9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 1195 additions and 60 deletions

View file

@ -0,0 +1,6 @@
---
'@astrojs/example-blog': minor
'@astrojs/example-blog-multiple-authors': minor
---
Update blog example template

View file

@ -0,0 +1,18 @@
# build output
dist
# dependencies
node_modules/
.snowpack/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# environment variables
.env
.env.production
# macOS-specific files
.DS_Store

View file

@ -0,0 +1,2 @@
## force pnpm to hoist
shamefully-hoist = true

View file

@ -0,0 +1,47 @@
# Astro Blog Example
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
Features:
- ✅ SEO-friendly setup with canonical URLs and OpenGraph data
- ✅ Full Markdown support
- ✅ RSS 2.0 generation
- ✅ Sitemap.xml generation
## 🚀 Project Structure
Inside of your Astro project, you'll see the following folders and files:
```
/
├── public/
│ ├── robots.txt
│ └── favicon.ico
├── src/
│ ├── components/
│ │ └── Tour.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 start` | Starts local dev server at `localhost:3000` |
| `npm run build` | Build your production site to `./dist/` |
## 👀 Want to learn more?
Feel free to check [our documentation](https://github.com/snowpackjs/astro) or jump into our [Discord server](https://astro.build/chat).

View file

@ -0,0 +1,14 @@
export default {
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
// pages: './src/pages', // Path to Astro components, pages, and data
// dist: './dist', // When running `astro build`, path to final static output
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that dont need processing.
buildOptions: {
site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
// sitemap: true, // Generate sitemap (set to "false" to disable)
},
devOptions: {
// port: 3000, // The port to run the dev server on.
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
},
};

View file

@ -0,0 +1,15 @@
{
"name": "@astrojs/example-blog-multiple-authors",
"version": "0.0.2",
"private": true,
"scripts": {
"start": "astro dev",
"build": "astro build"
},
"devDependencies": {
"astro": "^0.15.0"
},
"snowpack": {
"workspaceRoot": "../.."
}
}

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View file

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View file

@ -0,0 +1,11 @@
<svg width="256" height="256" fill="none" xmlns="http://www.w3.org/2000/svg">
<style>
#flame { fill: #FF5D01; }
#a { fill: #000014; }
@media (prefers-color-scheme: dark) {
#a { fill: #fff; }
}
</style>
<path id="a" fill-rule="evenodd" clip-rule="evenodd" d="M163.008 18.929c1.944 2.413 2.935 5.67 4.917 12.181l43.309 142.27a180.277 180.277 0 00-51.778-17.53l-28.198-95.29a3.67 3.67 0 00-7.042.01l-27.857 95.232a180.225 180.225 0 00-52.01 17.557l43.52-142.281c1.99-6.502 2.983-9.752 4.927-12.16a15.999 15.999 0 016.484-4.798c2.872-1.154 6.271-1.154 13.07-1.154h31.085c6.807 0 10.211 0 13.086 1.157a16.004 16.004 0 016.487 4.806z" />
<path id="flame" fill-rule="evenodd" clip-rule="evenodd" d="M168.19 180.151c-7.139 6.105-21.39 10.268-37.804 10.268-20.147 0-37.033-6.272-41.513-14.707-1.602 4.835-1.961 10.367-1.961 13.902 0 0-1.056 17.355 11.015 29.426 0-6.268 5.081-11.349 11.349-11.349 10.743 0 10.731 9.373 10.721 16.977v.679c0 11.542 7.054 21.436 17.086 25.606a23.27 23.27 0 01-2.339-10.2c0-11.008 6.463-15.107 13.974-19.87 5.976-3.79 12.616-8.001 17.192-16.449a31.024 31.024 0 003.743-14.82c0-3.299-.513-6.479-1.463-9.463z" />
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,25 @@
body {
font-family: 'Spectral', serif;
line-height: 1.4;
}
p {
line-height: 2;
}
a {
color: crimson;
}
img {
max-width: 100%;
height: auto;
}
.wrapper {
max-width: 60rem;
margin-left: auto;
margin-right: auto;
padding-left: 2rem;
padding-right: 2rem;
}

View file

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

View file

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View file

Before

Width:  |  Height:  |  Size: 164 KiB

After

Width:  |  Height:  |  Size: 164 KiB

View file

@ -0,0 +1,43 @@
---
import MainHead from '../components/MainHead.astro';
import Nav from '../components/Nav.astro';
import PostPreview from '../components/PostPreview.astro';
import Pagination from '../components/Pagination.astro';
// page
let title = 'Dons Blog';
let description = 'An example blog on Astro';
// collection
// note: we want to show first 3 posts here, but we dont want to paginate at /1, /2, /3, etc.
// so we show a preview of posts here, but actually paginate from $posts.astro
import authorData from '../data/authors.json';
let allPosts = Astro.fetchContent('./post/*.md');
allPosts.sort((a, b) => new Date(b.date) - new Date(a.date));
let firstPage = allPosts.slice(0, 2);
---
<html>
<head>
<title>{title}</title>
<MainHead
title={title}
description={description}
image={firstPage[0].image}
canonicalURL={Astro.request.canonicalURL.href}
/>
</head>
<body>
<Nav />
<main class="wrapper">
{firstPage.map((post) => <PostPreview post={post} author={authorData[post.author]} />)}
</main>
<footer>
<Pagination nextUrl="/posts/2" />
</footer>
</body>
</html>

View file

@ -1,14 +1,5 @@
export default {
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
// pages: './src/pages', // Path to Astro components, pages, and data
// dist: './dist', // When running `astro build`, path to final static output
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that dont need processing.
buildOptions: {
site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
// sitemap: true, // Generate sitemap (set to "false" to disable)
sitemap: true,
},
devOptions: {
// port: 3000, // The port to run the dev server on.
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
},
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

View file

@ -0,0 +1,272 @@
:root {
--font-fallback: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;
--font-body: "IBM Plex Sans", var(--font-fallback);
--font-mono: "IBM Plex Mono", Consolas, "Andale Mono WT", "Andale Mono",
"Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono",
"Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco,
"Courier New", Courier, monospace;
--color-white: #FFF;
--color-black: #000014;
--color-gray-50: #F9FAFB;
--color-gray-100: #F3F4F6;
--color-gray-200: #E5E7EB;
--color-gray-300: #D1D5DB;
--color-gray-400: #9CA3AF;
--color-gray-500: #6B7280;
--color-gray-600: #4B5563;
--color-gray-700: #374151;
--color-gray-800: #1F2937;
--color-gray-900: #111827;
--color-blue: #3894FF;
--color-blue-rgb: 56,148,255;
--color-green: #17C083;
--color-green-rgb: 23,192,131;
--color-orange: #FF5D01;
--color-orange-rgb: 255,93,1;
--color-purple: #882DE7;
--color-purple-rgb: 136,45,231;
--color-red: #FF1639;
--color-red-rgb: 255,22,57;
--color-yellow: #FFBE2D;
--color-yellow-rgb: 255,190,45;
}
:root {
color-scheme: light;
--theme-accent: var(--color-orange);
--theme-accent-rgb: var(--color-orange-rgb);
--theme-accent-opacity: 0.1;
--theme-divider: var(--color-gray-100);
--theme-text: var(--color-gray-800);
--theme-text-light: var(--color-gray-600);
--theme-text-lighter: var(--color-gray-400);
--theme-bg: var(--color-white);
--theme-bg-offset: var(--color-gray-100);
--theme-bg-accent: rgba(var(--theme-accent-rgb), var(--theme-accent-opacity));
--theme-code-inline-bg: var(--color-gray-100);
--theme-code-text: var(--color-gray-100);
--theme-code-bg: var(--color-gray-700);
}
body {
background: var(--theme-bg);
color: var(--theme-text);
}
:root.theme-dark {
color-scheme: dark;
--theme-accent-opacity: 0.3;
--theme-divider: var(--color-gray-900);
--theme-text: var(--color-gray-200);
--theme-text-light: var(--color-gray-400);
--theme-text-lighter: var(--color-gray-600);
--theme-bg: var(--color-black);
--theme-bg-offset: var(--color-gray-900);
--theme-code-inline-bg: var(--color-gray-800);
--theme-code-text: var(--color-gray-200);
--theme-code-bg: var(--color-gray-900);
}
::selection {
color: var(--theme-accent);
background-color: rgba(var(--theme-accent-rgb), var(--theme-accent-opacity));
}
* {
box-sizing: border-box;
margin: 0;
}
:root {
--user-font-scale: 1rem - 16px;
--max-width: calc(100% - 2rem);
}
@media (min-width: 50em) {
:root {
--max-width: 40em;
}
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
font-family: var(--font-body);
font-size: 1rem;
font-size: clamp(0.875rem, 0.4626rem + 1.0309vw + var(--user-font-scale), 1.125rem);
line-height: 1.625;
}
body {
width: 100%;
display: grid;
--gutter: 0.5rem;
--doc-padding: 2rem;
}
.layout {
display: grid;
grid-auto-flow: column;
grid-template-columns: minmax(var(--gutter), 1fr) minmax(0, var(--max-width)) minmax(var(--gutter), 1fr);
gap: 1em;
}
.layout > article {
grid-column: 2;
}
nav ul {
list-style: none;
padding: 0;
}
/* Typography */
:is(h1, h2, h3, h4, h5, h6) {
margin-bottom: 1.38rem;
font-weight: 400;
line-height: 1.3;
}
:is(h1, h2) {
max-width: 40ch;
}
:is(h2, h3):not(:first-child) {
margin-top: 3rem;
}
h1 {
font-size: clamp(2.488rem, 1.9240rem + 1.4100vw, 3.052rem);
}
h2 {
font-size: clamp(2.074rem, 1.7070rem + 0.9175vw, 2.441rem);
}
h3 {
font-size: clamp(1.728rem, 1.5030rem + 0.5625vw, 1.953rem);
}
h4 {
font-size: clamp(1.44rem, 1.3170rem + 0.3075vw, 1.563rem);
}
h5 {
font-size: clamp(1.2rem, 1.1500rem + 0.1250vw, 1.25rem);
}
p {
color: var(--theme-text-light);
}
small, .text_small {
font-size: 0.833rem;
}
a {
color: var(--theme-accent);
font-weight: 400;
text-underline-offset: 0.08em;
text-decoration: none;
align-items: center;
gap: 0.5rem;
}
a > code:not([class*="language"]) {
position: relative;
color: var(--theme-accent);
background: transparent;
text-underline-offset: var(--padding-block);
}
a > code:not([class*="language"])::before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: block;
background: var(--theme-accent);
opacity: var(--theme-accent-opacity);
border-radius: var(--border-radius);
}
a:hover,
a:focus {
text-decoration: underline;
}
a:focus {
outline: 2px solid currentColor;
outline-offset: 0.25em;
}
strong {
font-weight: 600;
color: inherit;
}
/* Supporting Content */
code:not([class*="language"]) {
--border-radius: 3px;
--padding-block: 0.2rem;
--padding-inline: 0.33rem;
font-family: var(--font-mono);
font-size: .85em;
color: inherit;
background-color: var(--theme-code-inline-bg);
padding: var(--padding-block) var(--padding-inline);
margin: calc(var(--padding-block) * -1) -0.125em;
border-radius: var(--border-radius);
}
pre > code:not([class*="language"]) {
background-color: transparent;
padding: 0;
margin: 0;
border-radius: 0;
color: inherit;
}
pre {
position: relative;
background-color: var(--theme-code-bg);
color: var(--theme-code-text);
--padding-block: 1rem;
--padding-inline: 2rem;
padding: var(--padding-block) var(--padding-inline);
padding-right: calc(var(--padding-inline) * 2);
margin-left: calc(50vw - var(--padding-inline));
transform: translateX(-50vw);
line-height: 1.414;
width: calc(100vw + (var(--padding-inline) * 2));
max-width: calc(100% + (var(--padding-inline) * 2));
overflow-y: hidden;
overflow-x: auto;
}
@media (min-width: 37.75em) {
pre {
--padding-inline: 1.25rem;
border-radius: 8px;
}
}
.flex {
display: flex;
align-items: center;
}
img.cover {
width: 100%;
max-height: 50vh;
object-fit: cover;
}

View file

@ -1,25 +1,99 @@
:root {
--font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
--font-mono: "IBM Plex Mono", Consolas, "Andale Mono WT", "Andale Mono",
"Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono",
"Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco,
"Courier New", Courier, monospace;
--color-green: #17c083;
}
* {
box-sizing: border-box;
margin: 0;
}
html {
display: grid;
width: 100%;
max-width: 100vw;
overflow: hidden;
height: 100%;
background-color: #000014;
}
html, body {
padding: 0;
font-size: clamp(14px, calc(1rem + (3vw - 1.2rem)), 20px);
font-family: var(--font-sans);
font-weight: 400;
background-image: radial-gradient(
87.7% 87.7% at 85.6% 18.14%,
#111827 0%,
#000014 100%
);
background-repeat: no-repeat;
color: #f3f4f6;
}
body {
font-family: 'Spectral', serif;
line-height: 1.4;
position: relative;
display: grid;
place-items: center;
min-width: 100%;
max-width: 100vw;
min-height: 100vh;
overflow-x: hidden;
}
p {
line-height: 2;
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
a {
color: crimson;
}
position: relative;
text-decoration: none;
color: var(--color-green);
padding: 0.05em 0.125em;
margin: -0.05em -0.125em;
transition: color 120ms cubic-bezier(0.23, 1, 0.320, 1);
z-index: 0;
display: inline-block;
img {
max-width: 100%;
height: auto;
}
&:hover,
&:focus {
color: rgba(0, 0, 0, 1);
.wrapper {
max-width: 60rem;
margin-left: auto;
margin-right: auto;
padding-left: 2rem;
padding-right: 2rem;
&::before {
transform: scaleY(1);
background: var(--color-green);
}
}
&:visited {
// color: var(--color-green);
color: var(--color-green);
&:hover,
&:focus {
color: rgba(0, 0, 0, 1);
}
}
&::before {
transform-origin: bottom center;
content: '';
display: block;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
inset: 0;
background: var(--color-green);
pointer-events: none;
transform: scaleY(0.05);
transition: transform 120ms cubic-bezier(0.23, 1, 0.320, 1),
background 120ms cubic-bezier(0.23, 1, 0.320, 1);
z-index: -1;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View file

@ -0,0 +1,16 @@
---
export interface Props {
name: string;
href: string;
}
const { name, href } = Astro.props;
---
<style>
.author {
margin-bottom: 0.75rem;
}
</style>
<div class="author">
<p><a href={href}>{name}</a></p>
</div>

View file

@ -0,0 +1,36 @@
---
export interface Props {
title: string;
description: string;
permalink: string;
}
const { title, description, permalink } = Astro.props;
---
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<!-- Primary Meta Tags -->
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content={permalink} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content="https://astro.build/social.jpg?v=1" />
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={permalink} />
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
<meta property="twitter:image" content="https://astro.build/social.jpg?v=1" />
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=IBM+Plex+Sans:wght@400;700&display=swap">

View file

@ -0,0 +1,90 @@
<header class="layout">
<article>
<h1>
<a href="/">
<svg class="logo" width="32" height="32" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
<style>
#flame {
fill: #ff5d01;
}
#a {
fill: #000014;
}
</style>
<title>Logo</title>
<path
id="a"
fill-rule="evenodd"
clip-rule="evenodd"
d="M163.008 18.929c1.944 2.413 2.935 5.67 4.917 12.181l43.309 142.27a180.277 180.277 0 00-51.778-17.53l-28.198-95.29a3.67 3.67 0 00-7.042.01l-27.857 95.232a180.225 180.225 0 00-52.01 17.557l43.52-142.281c1.99-6.502 2.983-9.752 4.927-12.16a15.999 15.999 0 016.484-4.798c2.872-1.154 6.271-1.154 13.07-1.154h31.085c6.807 0 10.211 0 13.086 1.157a16.004 16.004 0 016.487 4.806z"
/>
<path
id="flame"
fill-rule="evenodd"
clip-rule="evenodd"
d="M168.19 180.151c-7.139 6.105-21.39 10.268-37.804 10.268-20.147 0-37.033-6.272-41.513-14.707-1.602 4.835-1.961 10.367-1.961 13.902 0 0-1.056 17.355 11.015 29.426 0-6.268 5.081-11.349 11.349-11.349 10.743 0 10.731 9.373 10.721 16.977v.679c0 11.542 7.054 21.436 17.086 25.606a23.27 23.27 0 01-2.339-10.2c0-11.008 6.463-15.107 13.974-19.87 5.976-3.79 12.616-8.001 17.192-16.449a31.024 31.024 0 003.743-14.82c0-3.299-.513-6.479-1.463-9.463z"
/>
</svg>
<span>My Blog</span>
</a>
</h1>
</article>
</header>
<style>
header {
padding-top: 1rem;
padding-bottom: 1rem;
height: 5rem;
}
article {
display: flex;
align-items: center;
justify-content: space-between;
}
.header-subitem {
display: flex;
flex-grow: 0;
gap: 0.5em;
align-items: center;
justify-content: center;
color: var(--theme-text-lighter);
font-size: initial;
padding: 0.5rem;
}
.header-subitem:hover {
color: var(--theme-accent);
}
.header-subitem svg {
width: 1.5rem;
height: 1.5rem;
}
@media (max-width: 32em) {
.header-subitem {
display: none;
}
}
h1 {
margin: 0;
font-size: 1.5rem;
max-width: 100%;
display: flex;
flex-grow: 1;
}
.logo {
transform: translateY(0.25rem);
}
svg {
width: 2.5rem;
height: 2.5rem;
}
h1 a {
text-decoration: none;
display: inline-flex;
}
</style>

View file

@ -0,0 +1,86 @@
---
import Author from './Author.astro';
export interface Props {
title: string;
author: string;
publishDate: string;
heroImage: string;
}
const { title, author, publishDate, heroImage } = Astro.props;
---
<div class="layout">
<article class="content">
<div>
<header>
{heroImage && <img width="720" height="420" class="hero-image" loading="lazy" src={heroImage} />}
<p class="publish-date">{publishDate}</p>
<h1 class="title">{title}</h1>
<Author name="@FredKSchott" url="https://twitter.com/FredKSchott" />
</header>
<main>
<slot />
</main>
</article>
</div>
<style>
.hero-image {
width: 100vw;
object-fit: cover;
object-position: center;
margin-top: 2rem;
margin-bottom: 4rem;
max-width: 1280px;
}
@media (max-width: 50em) {
.hero-image {
height: 260px;
margin-top: 0;
margin-bottom: 2rem;
}
}
.content {
margin-bottom: 8rem;
}
.content :global(main > * + *) {
margin-top: 1rem;
}
.content :global(h2) {
margin-top: 4rem;
}
header {
display: flex;
flex-direction: column;
text-align: center;
align-items: center;
justify-content: center;
padding-bottom: 2rem;
margin-bottom: 2rem;
border-bottom: 4px solid var(--theme-divider);
}
.title,
.author,
.publish-date {
margin: 0;
}
.publish-date,
.author {
color: var(--theme-text-lighter);
}
.title {
font-size: 2.25rem;
font-weight: 700;
}
</style>

View file

@ -0,0 +1,57 @@
---
export interface Props {
post: any;
}
const { post } = Astro.props;
---
<article class="post-preview">
<header>
<h3 class="publish-date">{post.publishDate}</h3>
<a href={post.url}><h1 class="title">{post.title}</h1></a>
</header>
<main>
<p>{post.description}</p>
<a href={post.url}>Read more</a>
</main>
</article>
<style>
.content :global(main > * + *) {
margin-top: 1rem;
}
.post-preview {
padding-bottom: 2rem;
margin-bottom: 2rem;
border-bottom: 4px solid var(--theme-divider);
}
header {
display: flex;
flex-direction: column;
text-align: left;
align-items: flex-start;
justify-content: center;
padding-bottom: 2rem;
}
.title,
.author,
.publish-date {
margin: 0;
}
.publish-date,
.author {
font-size: 1.25rem;
color: var(--theme-text-lighter);
}
.title {
font-size: 2.25rem;
font-weight: 700;
color: var(--theme-text);
}
</style>

View file

@ -0,0 +1,56 @@
<svg class="logo" width="158" height="170" viewBox="0 0 158 170" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M96.5039 9.46441C97.4758 10.671 97.9714 12.2991 98.9626 15.5553L120.617 86.6902C112.611 82.5368 103.907 79.5413 94.7281 77.9252L80.6289 30.2798C80.3982 29.5002 79.6822 28.9654 78.8692 28.9654C78.0541 28.9654 77.3367 29.503 77.1079 30.2853L63.1795 77.9011C53.9579 79.51 45.2146 82.5109 37.1741 86.6793L58.9347 15.5388C59.929 12.2882 60.4262 10.6629 61.3981 9.45854C62.2562 8.39532 63.3723 7.56959 64.64 7.06003C66.076 6.48285 67.7756 6.48285 71.1749 6.48285H86.7174C90.1211 6.48285 91.823 6.48285 93.2603 7.06124C94.5291 7.575 95.6459 8.39925 96.5039 9.46441Z" fill="white" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M99.0951 90.0755C95.5253 93.1279 88.4002 95.2097 80.1929 95.2097C70.1197 95.2097 61.6767 92.0737 59.4363 87.8561C58.6354 90.2733 58.4558 93.0397 58.4558 94.8069C58.4558 94.8069 57.9281 103.485 63.9636 109.52C63.9636 106.386 66.5042 103.846 69.6381 103.846C75.0097 103.846 75.0036 108.532 74.9987 112.334C74.9986 112.448 74.9984 112.561 74.9984 112.673C74.9984 118.444 78.5255 123.391 83.5416 125.477C82.7924 123.936 82.3721 122.205 82.3721 120.377C82.3721 114.873 85.6034 112.823 89.3588 110.441C92.3469 108.546 95.6668 106.441 97.9548 102.217C99.1486 100.013 99.8265 97.4893 99.8265 94.8069C99.8265 93.1573 99.5702 91.5676 99.0951 90.0755Z" fill="#FF5D01" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M99.0951 90.0755C95.5253 93.1279 88.4002 95.2097 80.1929 95.2097C70.1197 95.2097 61.6767 92.0737 59.4363 87.8561C58.6354 90.2733 58.4558 93.0397 58.4558 94.8069C58.4558 94.8069 57.9281 103.485 63.9636 109.52C63.9636 106.386 66.5042 103.846 69.6381 103.846C75.0097 103.846 75.0036 108.532 74.9987 112.334C74.9986 112.448 74.9984 112.561 74.9984 112.673C74.9984 118.444 78.5255 123.391 83.5416 125.477C82.7924 123.936 82.3721 122.205 82.3721 120.377C82.3721 114.873 85.6034 112.823 89.3588 110.441C92.3469 108.546 95.6668 106.441 97.9548 102.217C99.1486 100.013 99.8265 97.4893 99.8265 94.8069C99.8265 93.1573 99.5702 91.5676 99.0951 90.0755Z" fill="url(#paint1_linear)" />
<path d="M11.9957 169.024C20.0117 169.024 24.8597 167.104 27.6917 163.12C27.6917 164.896 27.7877 166.576 28.0277 168.112H32.7797C32.3477 165.616 32.2517 163.984 32.2517 159.472V153.328C32.2517 146.704 27.1157 143.2 17.3237 143.2C7.8677 143.2 1.7237 146.848 0.955701 152.128H5.9957C6.7637 148.576 10.7477 146.704 17.3237 146.704C23.8037 146.704 27.6437 148.96 27.6437 152.8V153.28L12.6677 154.144C6.5717 154.48 4.3157 155.344 2.5877 156.592C0.955701 157.792 0.0437012 159.664 0.0437012 161.824C0.0437012 166.384 4.7477 169.024 11.9957 169.024ZM13.5317 165.616C7.9637 165.616 4.8917 164.32 4.8917 161.728C4.8917 158.944 6.8117 157.696 13.5797 157.264L27.6437 156.4V157.504C27.6437 162.544 21.7397 165.616 13.5317 165.616Z" fill="white" />
<path d="M55.9352 169.024C65.8712 169.024 69.8552 165.76 69.8552 161.008C69.8552 157.072 67.4072 155.056 61.1672 154.528L49.5032 153.616C46.3352 153.376 44.5592 152.464 44.5592 150.496C44.5592 148 47.2952 146.704 53.1992 146.704C59.9192 146.704 63.4232 148.048 65.7272 151.024L69.6152 149.152C67.2152 145.408 61.8872 143.2 53.6312 143.2C45.1352 143.2 40.0472 146.032 40.0472 150.688C40.0472 154.864 43.0712 156.88 48.7832 157.36L60.3512 158.272C64.1432 158.56 65.2952 159.328 65.2952 161.296C65.2952 164.128 62.3672 165.472 56.5592 165.472C49.5032 165.472 45.0392 163.552 42.8792 160.048L39.0872 162.112C42.0152 166.528 47.1512 169.024 55.9352 169.024Z" fill="white" />
<path d="M79.6765 147.712V159.28C79.6765 164.032 81.3085 168.784 90.1885 168.784C92.4445 168.784 95.1805 168.352 96.3805 167.824V163.936C94.7005 164.32 92.6845 164.608 90.7165 164.608C86.5405 164.608 84.2845 162.976 84.2845 158.848V147.712H96.2845V144.112H84.2845V136L79.6765 137.872V144.112H72.1404V147.712H79.6765Z" fill="white" />
<path d="M107.728 144.112H103.504V168.112H108.064V159.136C108.064 155.68 108.736 152.752 110.656 150.736C112.336 148.864 114.496 147.808 118.288 147.808C119.584 147.808 120.4 147.904 121.504 148.096V143.68C120.496 143.44 119.632 143.392 118.336 143.392C113.2 143.392 109.12 146.416 107.728 151.072V144.112Z" fill="white" />
<path d="M140.724 169.024C150.948 169.024 157.956 163.84 157.956 156.112C157.956 148.384 150.948 143.2 140.724 143.2C130.5 143.2 123.492 148.384 123.492 156.112C123.492 163.84 130.5 169.024 140.724 169.024ZM140.724 165.232C133.188 165.232 128.34 161.68 128.34 156.112C128.34 150.544 133.188 146.992 140.724 146.992C148.212 146.992 153.108 150.544 153.108 156.112C153.108 161.68 148.212 165.232 140.724 165.232Z" fill="white" />
<defs>
<linearGradient id="paint1_linear" x1="115.168" y1="65.245" x2="94.0326" y2="109.491" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF1639" />
<stop offset="1" stop-color="#FF1639" stop-opacity="0" />
</linearGradient>
</defs>
</svg>
<style lang="scss">
.logo {
margin: 2rem auto;
}
.title {
font-family: var(--font-sans);
font-size: 1rem;
}
.title svg {
margin-right: -100%;
}
.title svg text {
font-size: 16px;
font-family: var(--font-sans);
}
.title svg text.span {
fill: white;
font-size: 16.2px;
transform: translate(0, 18px);
}
.title svg text.em {
fill: var(--color-green);
transform: translate(0, 36px);
}
@media (min-width: 40em) {
.title svg {
margin-right: 0;
margin-bottom: -40px;
}
.title svg text.span {
font-size: 16px;
}
.title svg text.em {
transform: translate(190px, 18px);
}
}
</style>

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -0,0 +1,23 @@
---
import { Markdown } from 'astro/components';
import BaseHead from '../components/BaseHead.astro';
import BlogHeader from '../components/BlogHeader.astro';
import BlogPost from '../components/BlogPost.astro';
const {content} = Astro.props;
const {title, description, publishDate, author, heroImage, permalink} = content;
---
<html>
<head>
<BaseHead title={title} description={description} permalink={permalink} />
<link rel="stylesheet" href="/blog.css" />
</head>
<body>
<BlogHeader />
<BlogPost title={title} author={author} heroImage={heroImage} publishDate={publishDate}>
<slot />
</BlogPost>
</body>
</html>

View file

@ -1,43 +1,77 @@
---
import MainHead from '../components/MainHead.astro';
import Nav from '../components/Nav.astro';
import PostPreview from '../components/PostPreview.astro';
import Pagination from '../components/Pagination.astro';
import BaseHead from '../components/BaseHead.astro';
import BlogHeader from '../components/BlogHeader.astro';
import BlogPostPreview from '../components/BlogPostPreview.astro';
// page
let title = 'Dons Blog';
let description = 'An example blog on Astro';
let title = 'Example Blog';
let description = 'The perfect starter for your perfect blog.';
let permalink = 'https://example.com/';
// collection
// note: we want to show first 3 posts here, but we dont want to paginate at /1, /2, /3, etc.
// so we show a preview of posts here, but actually paginate from $posts.astro
import authorData from '../data/authors.json';
let allPosts = Astro.fetchContent('./post/*.md');
allPosts.sort((a, b) => new Date(b.date) - new Date(a.date));
let firstPage = allPosts.slice(0, 2);
let allPosts = Astro.fetchContent('./posts/*.md');
allPosts = allPosts.sort((a, b) => new Date(b.date) - new Date(a.date));
---
<html>
<head>
<title>{title}</title>
<MainHead
title={title}
description={description}
image={firstPage[0].image}
canonicalURL={Astro.request.canonicalURL.href}
/>
<BaseHead title={title} description={description} permalink={permalink} />
<link rel="stylesheet" href="/blog.css" />
<style>
body {
width: 100%;
display: grid;
grid-template-rows: 3.5rem 1fr;
--gutter: 0.5rem;
--doc-padding: 2rem;
}
header {
width: 100%;
height: 100%;
background-color: var(--theme-bg-offset);
display: flex;
align-items: center;
justify-content: center;
}
.content {
margin-top: 4rem;
margin-bottom: 8rem;
}
.content :global(main > * + *) {
margin-top: 1rem;
}
.intro {
padding-bottom: 4rem;
margin-bottom: 2rem;
border-bottom: 4px solid var(--theme-divider);
}
.intro > * {
margin: 0;
}
.latest {
font-size: 2.5rem;
font-weight: 700;
}
</style>
</head>
<body>
<Nav />
<main class="wrapper">
{firstPage.map((post) => <PostPreview post={post} author={authorData[post.author]} />)}
</main>
<footer>
<Pagination nextUrl="/posts/2" />
</footer>
<BlogHeader />
<div class="layout">
<article class="content">
<section class="intro">
<h1 class="latest">{title}</h1>
<p>{description}</p>
</section>
<section>
{allPosts.map(p => <BlogPostPreview post={p} />)}
</section>
</article>
</div>
</body>
</html>

View file

@ -0,0 +1,90 @@
---
title: 'Introducing Astro: Ship Less JavaScript'
description: "We're excited to announce Astro as a new way to build static websites and deliver lightning-fast performance without sacrificing a modern developer experience."
publishDate: 'Tuesday, June 8 2021'
author: 'fred'
heroImage: '/social.jpg'
layout: '../../layouts/BlogPost.astro'
---
There's a simple secret to building a faster website — *just ship less*.
Unfortunately, modern web development has been trending in the opposite direction—towards *more.* More JavaScript, more features, more moving parts, and ultimately more complexity needed to keep it all running smoothly.
Today I'm excited to publicly share Astro: a new kind of static site builder that delivers lightning-fast performance with a modern developer experience. To design Astro, we borrowed the best parts of our favorite tools and then added a few innovations of our own, including:
- **Bring Your Own Framework (BYOF):** Build your site using React, Svelte, Vue, Preact, web components, or just plain ol' HTML + JavaScript.
- **100% Static HTML, No JS:** Astro renders your entire page to static HTML, removing all JavaScript from your final build by default.
- **On-Demand Components:** Need some JS? Astro can automatically hydrate interactive components when they become visible on the page. If the user never sees it, they never load it.
- **Fully-Featured:** Astro supports TypeScript, Scoped CSS, CSS Modules, Sass, Tailwind, Markdown, MDX, and any of your favorite npm packages.
- **SEO Enabled:** Automatic sitemaps, RSS feeds, pagination and collections take the pain out of SEO and syndication.
This post marks the first public beta release of Astro. **Missing features and bugs are still to be expected at this early stage.** There are still some months to go before an official 1.0 release, but there are already several fast sites built with Astro in production today. We would love your early feedback as we move towards a v1.0 release later this year.
<Note>
To learn more about Astro and start building your first site, check out [the project README.](https://github.com/snowpackjs/astro#-guides)
</Note>
## Getting Started
Starting a new project in Astro is easy:
```shell
# create your project
mkdir new-project-directory
cd new-project-directory
npm init astro
# install your dependencies
npm install
# start the dev server and open your browser
npm start
```
> To learn more about Astro and start building your first site, check out [the project README.](https://github.com/snowpackjs/astro#-guides).
## How Astro Works
Astro works a lot like a static site generator. If you have ever used Eleventy, Hugo, or Jekyll (or even a server-side web framework like Rails, Laravel, or Django) then you should feel right at home with Astro.
In Astro, you compose your website using UI components from your favorite JavaScript web framework (React, Svelte, Vue, etc). Astro renders your entire site to static HTML during the build. The result is a fully static website with all JavaScript removed from the final page. No monolithic JavaScript application required, just static HTML that loads as fast as possible in the browser regardless of how many UI components you used to generate it.
Of course, sometimes client-side JavaScript is inevitable. Image carousels, shopping carts, and auto-complete search bars are just a few examples of things that require some JavaScript to run in the browser. This is where Astro really shines: When a component needs some JavaScript, Astro only loads that one component (and any dependencies). The rest of your site continues to exist as static, lightweight HTML.
In other full-stack web frameworks this level of per-component optimization would be impossible without loading the entire page in JavaScript, delaying interactivity. In Astro, this kind of [partial hydration](https://addyosmani.com/blog/rehydration/) is built into the tool itself.
You can even [automatically defer components](https://codepen.io/jonneal/full/ZELvMvw) to only load once they become visible on the page with the `:visible` modifier.
This new approach to web architecture is called [islands architecture](https://jasonformat.com/islands-architecture/). We didn't coin the term, but Astro may have perfected the technique. We are confident that an HTML-first, JavaScript-only-as-needed approach is the best solution for the majority of content-based websites.
> To learn more about Astro and start building your first site, check out [the project README.](https://github.com/snowpackjs/astro#-guides)
## Embracing the Pit of Success
<BlockQuote author="Jeff Atwood" source="Falling Into The Pit of Success" sourceHref="https://blog.codinghorror.com/falling-into-the-pit-of-success/">
A well-designed system makes it easy to do the right things and annoying (but not impossible) to do the wrong things
</BlockQuote>
Poor performance is often framed as a failure of the developer, but we respectfully disagree. In many cases, poor performance is a failure of tooling. It should be difficult to build a slow website.
Astro's main design principle is to lead developers into what [Rico Mariani](https://twitter.com/ricomariani) dubbed "the pit of success". It is our goal to build every site "fast by default" while also delivering a familiar, modern developer experience.
By building your site to static HTML by default, Astro makes it difficult (but never impossible 😉) to build a slow site.
## Long-Term Sustainability
Astro is built by the team of open source developers behind [Snowpack](https://snowpack.dev) and [Skypack](https://skypack.dev), with additional contributions from the community.
**Astro is and always will be free.** It is an open source project released under the [MIT license](https://github.com/snowpackjs/astro/blob/main/LICENSE).
We care deeply about building a more sustainable future for open source software. At the same time, we need to support Astro's development long-term. This requires money (donations alone aren't enough.)
We're inspired by the early success of projects like [Tailwind](https://tailwindcss.com/), [Rome](https://rome.tools/), [Remix](https://remix.run/), [Ionic](https://ionicframework.com/), and others who are experimenting with long-term financial sustainability on top of Open Source. Over the next year we'll be exploring how we can create a sustainable business to support a 100% free, open source Astro for years to come.
If your company is as excited about Astro as we are, [we'd love to hear from you.](https://astro.build/chat)
Finally, I'd like to give a **HUGE** thanks to the 300+ developers who joined our earliest private beta. Your feedback has been essential in shaping Astro into the tool it is today. If you're interested in getting involved (or just following along with development) please [join us on Discord.](https://astro.build/chat)
> To learn more about Astro and start building your first site, check out [the project README.](https://github.com/snowpackjs/astro#-guides)

View file

@ -0,0 +1,129 @@
---
import { Markdown } from 'astro/components';
import BaseHead from '../../components/BaseHead.astro';
import BlogHeader from '../../components/BlogHeader.astro';
import BlogPost from '../../components/BlogPost.astro';
import BlockQuote from '../../components/BlockQuote.astro';
import Note from '../../components/Note.astro';
import Shell from '../../components/Shell.astro';
let title = 'Introducing Astro: Ship Less JavaScript';
let description = `We're excited to announce Astro as a new way to build static websites and deliver lightning-fast performance without sacrificing a modern developer experience.`;
let publishDate = 'Tuesday, June 8 2021';
let author = 'fred';
let heroImage = '/social.jpg';
let permalink = 'https://astro.build/blog/introducing-astro';
---
<html>
<head>
<BaseHead title={title} description={description} permalink={permalink} />
<link rel="stylesheet" href="/blog.css" />
</head>
<body>
<BlogHeader />
<BlogPost title={title} author={author} heroImage={heroImage} publishDate={publishDate}>
<Markdown>
There's a simple secret to building a faster website — *just ship less*.
Unfortunately, modern web development has been trending in the opposite direction—towards *more.* More JavaScript, more features, more moving parts, and ultimately more complexity needed to keep it all running smoothly.
Today I'm excited to publicly share Astro: a new kind of static site builder that delivers lightning-fast performance with a modern developer experience. To design Astro, we borrowed the best parts of our favorite tools and then added a few innovations of our own, including:
- **Bring Your Own Framework (BYOF):** Build your site using React, Svelte, Vue, Preact, web components, or just plain ol' HTML + JavaScript.
- **100% Static HTML, No JS:** Astro renders your entire page to static HTML, removing all JavaScript from your final build by default.
- **On-Demand Components:** Need some JS? Astro can automatically hydrate interactive components when they become visible on the page. If the user never sees it, they never load it.
- **Fully-Featured:** Astro supports TypeScript, Scoped CSS, CSS Modules, Sass, Tailwind, Markdown, MDX, and any of your favorite npm packages.
- **SEO Enabled:** Automatic sitemaps, RSS feeds, pagination and collections take the pain out of SEO and syndication.
This post marks the first public beta release of Astro. **Missing features and bugs are still to be expected at this early stage.** There are still some months to go before an official 1.0 release, but there are already several fast sites built with Astro in production today. We would love your early feedback as we move towards a v1.0 release later this year.
<Note>
To learn more about Astro and start building your first site, check out [the project README.](https://github.com/snowpackjs/astro#-guides)
</Note>
## Getting Started
Starting a new project in Astro is easy:
<Shell code={`
# create your project
mkdir new-project-directory
cd new-project-directory
npm init astro
# install your dependencies
npm install
# start the dev server and open your browser
npm start
`} />
<Note>
To learn more about Astro and start building your first site, check out [the project README.](https://github.com/snowpackjs/astro#-guides)
</Note>
## How Astro Works
Astro works a lot like a static site generator. If you have ever used Eleventy, Hugo, or Jekyll (or even a server-side web framework like Rails, Laravel, or Django) then you should feel right at home with Astro.
In Astro, you compose your website using UI components from your favorite JavaScript web framework (React, Svelte, Vue, etc). Astro renders your entire site to static HTML during the build. The result is a fully static website with all JavaScript removed from the final page. No monolithic JavaScript application required, just static HTML that loads as fast as possible in the browser regardless of how many UI components you used to generate it.
Of course, sometimes client-side JavaScript is inevitable. Image carousels, shopping carts, and auto-complete search bars are just a few examples of things that require some JavaScript to run in the browser. This is where Astro really shines: When a component needs some JavaScript, Astro only loads that one component (and any dependencies). The rest of your site continues to exist as static, lightweight HTML.
In other full-stack web frameworks this level of per-component optimization would be impossible without loading the entire page in JavaScript, delaying interactivity. In Astro, this kind of [partial hydration](https://addyosmani.com/blog/rehydration/) is built into the tool itself.
You can even [automatically defer components](https://codepen.io/jonneal/full/ZELvMvw) to only load once they become visible on the page with the `:visible` modifier.
This new approach to web architecture is called [islands architecture](https://jasonformat.com/islands-architecture/). We didn't coin the term, but Astro may have perfected the technique. We are confident that an HTML-first, JavaScript-only-as-needed approach is the best solution for the majority of content-based websites.
<Note>
To learn more about Astro and start building your first site, check out [the project README.](https://github.com/snowpackjs/astro#-guides)
</Note>
## Embracing the Pit of Success
<BlockQuote author="Jeff Atwood" source="Falling Into The Pit of Success" sourceHref="https://blog.codinghorror.com/falling-into-the-pit-of-success/">
A well-designed system makes it easy to do the right things and annoying (but not impossible) to do the wrong things
</BlockQuote>
Poor performance is often framed as a failure of the developer, but we respectfully disagree. In many cases, poor performance is a failure of tooling. It should be difficult to build a slow website.
Astro's main design principle is to lead developers into what [Rico Mariani](https://twitter.com/ricomariani) dubbed "the pit of success". It is our goal to build every site "fast by default" while also delivering a familiar, modern developer experience.
By building your site to static HTML by default, Astro makes it difficult (but never impossible 😉) to build a slow site.
## Long-Term Sustainability
Astro is built by the team of open source developers behind [Snowpack](https://snowpack.dev) and [Skypack](https://skypack.dev), with additional contributions from the community.
**Astro is and always will be free.** It is an open source project released under the [MIT license](https://github.com/snowpackjs/astro/blob/main/LICENSE).
We care deeply about building a more sustainable future for open source software. At the same time, we need to support Astro's development long-term. This requires money (donations alone aren't enough.)
We're inspired by the early success of projects like [Tailwind](https://tailwindcss.com/), [Rome](https://rome.tools/), [Remix](https://remix.run/), [Ionic](https://ionicframework.com/), and others who are experimenting with long-term financial sustainability on top of Open Source. Over the next year we'll be exploring how we can create a sustainable business to support a 100% free, open source Astro for years to come.
If your company is as excited about Astro as we are, [we'd love to hear from you.](https://astro.build/chat)
Finally, I'd like to give a **HUGE** thanks to the 300+ developers who joined our earliest private beta. Your feedback has been essential in shaping Astro into the tool it is today. If you're interested in getting involved (or just following along with development) please [join us on Discord.](https://astro.build/chat)
<Note>
To learn more about Astro and start building your first site, check out [the project README.](https://github.com/snowpackjs/astro#-guides)
</Note>
</Markdown>
</BlogPost>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-TEL60V1WM9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-TEL60V1WM9');
</script>
</body>
</html>