Skip to content

Commit

Permalink
Merge branch 'main' into preact-prepass-render
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandrjet authored Dec 29, 2023
2 parents 94e143e + a2977cb commit 2c6b96e
Show file tree
Hide file tree
Showing 46 changed files with 1,332 additions and 82 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-snakes-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes remote images with encoded characters
5 changes: 5 additions & 0 deletions .changeset/weak-oranges-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

`<Image />` srcset now parses encoded paths correctly
4 changes: 2 additions & 2 deletions examples/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export default function createIntegration(): AstroIntegration {
// See the @astrojs/react integration for an example
// https://github.com/withastro/astro/blob/main/packages/integrations/react/src/index.ts
},
'astro:build:setup': ({ pages, updateConfig }) => {
'astro:build:setup': () => {
// See the @astrojs/lit integration for an example
// https://github.com/withastro/astro/blob/main/packages/integrations/lit/src/index.ts
},
'astro:build:done': ({ dir, routes }) => {
'astro:build:done': () => {
// See the @astrojs/partytown integration for an example
// https://github.com/withastro/astro/blob/main/packages/integrations/partytown/src/index.ts
},
Expand Down
3 changes: 3 additions & 0 deletions examples/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"@astrojs/node": "^7.0.3",
"astro": "^4.0.8",
"html-minifier": "^4.0.0"
},
"devDependencies": {
"@types/html-minifier": "^4.0.5"
}
}
7 changes: 5 additions & 2 deletions examples/middleware/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import htmlMinifier from 'html-minifier';

const limit = 50;

const loginInfo = {
const loginInfo: {
token: undefined | string;
currentTime: undefined | number;
} = {
token: undefined,
currentTime: undefined,
};

export const minifier = defineMiddleware(async (context, next) => {
export const minifier = defineMiddleware(async (_context, next) => {
const response = await next();
// check if the response is returning some HTML
if (response.headers.get('content-type') === 'text/html') {
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function get<T>(
});
if (!response.ok) {
// TODO make this better...
return null;
throw new Error('Fetch failed');
}
return cb(response);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ssr/src/pages/api/cart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIContext } from 'astro';
import type { APIContext } from 'astro';
import { userCartItems } from '../../models/session';

export function GET({ cookies }: APIContext) {
Expand All @@ -21,7 +21,7 @@ interface AddToCartItem {
export async function POST({ cookies, request }: APIContext) {
const item: AddToCartItem = await request.json();

let userId = cookies.get('user-id').value;
let userId = cookies.get('user-id')?.value;

if (!userCartItems.has(userId)) {
userCartItems.set(userId, new Map());
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr/src/pages/login.form.async.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIContext, APIRoute } from 'astro';
import type { APIContext, APIRoute } from 'astro';

export const POST: APIRoute = ({ cookies }: APIContext) => {
// add a new cookie
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr/src/pages/login.form.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIContext } from 'astro';
import type { APIContext } from 'astro';

export function POST({ cookies }: APIContext) {
// add a new cookie
Expand Down
7 changes: 7 additions & 0 deletions examples/starlog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Starlog

## Release notes theme for Astro

![starlog-gh](https://github.com/doodlemarks/starlog/assets/2244813/9c5c2e46-665a-437e-a971-053db4dbff63)

Built with Astro and Sass. Supports both dark and light modes.
6 changes: 6 additions & 0 deletions examples/starlog/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
site: 'https://example.com',
});
17 changes: 17 additions & 0 deletions examples/starlog/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@example/starlog",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"astro": "^4.0.5",
"sass": "^1.69.5",
"sharp": "^0.32.5"
}
}
9 changes: 9 additions & 0 deletions examples/starlog/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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions examples/starlog/src/components/BaseHead.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
import { ViewTransitions } from 'astro:transitions';
import SEO, { type Props as SEOProps } from './SEO.astro';
import { SiteTitle, SiteDescription } from '../consts';
export type Props = Partial<SEOProps>;
const { title = SiteTitle, name = SiteTitle, description = SiteDescription, ...seo } = Astro.props;
---

<SEO {title} {description} {name} {...seo} />

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Source+Code+Pro&display=swap"
rel="stylesheet"
/>

<ViewTransitions />
12 changes: 12 additions & 0 deletions examples/starlog/src/components/Footer.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
import '../styles/global.scss';
---

<footer>
<p>© 2023</p>
<div class="footer_links">
<a href="#">Discord</a>
<a href="#">X</a>
<a href="#">GitHub</a>
</div>
</footer>
25 changes: 25 additions & 0 deletions examples/starlog/src/components/FormattedDate.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
import type { HTMLAttributes } from 'astro/types';
type Props = HTMLAttributes<'time'> & {
date: Date;
};
const { date, ...attrs } = Astro.props;
---

<time datetime={date.toISOString()} {...attrs}>
{
date.toLocaleDateString('en-us', {
year: 'numeric',
month: 'short',
day: 'numeric',
})
}
</time>

<style>
time {
display: block;
}
</style>
54 changes: 54 additions & 0 deletions examples/starlog/src/components/Header.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
import '../styles/global.scss';
import { SiteTitle } from '../consts';
---

<header>
<nav>
<h2 id="site_title">
<a href="/">
<svg
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="none"
><path
fill="url(#a)"
fill-rule="evenodd"
d="M.654 3.276C0 4.56 0 6.24 0 9.6v4.8c0 3.36 0 5.04.654 6.324a6 6 0 0 0 2.622 2.622C4.56 24 6.24 24 9.6 24h4.8c3.36 0 5.04 0 6.324-.654a6 6 0 0 0 2.622-2.622C24 19.44 24 17.76 24 14.4V9.6c0-3.36 0-5.04-.654-6.324A6 6 0 0 0 20.724.654C19.44 0 17.76 0 14.4 0H9.6C6.24 0 4.56 0 3.276.654A6 6 0 0 0 .654 3.276Zm10.875 16.41a.5.5 0 0 0 .942 0l.628-1.754a8 8 0 0 1 4.833-4.833l1.754-.628a.5.5 0 0 0 0-.942l-1.754-.628A8 8 0 0 1 13.1 6.068l-.628-1.754a.5.5 0 0 0-.942 0l-.628 1.754A8 8 0 0 1 6.068 10.9l-1.754.628a.5.5 0 0 0 0 .942l1.754.628a8 8 0 0 1 4.833 4.833l.628 1.754Z"
clip-rule="evenodd"></path><path
stroke="url(#b)"
stroke-opacity=".5"
stroke-width=".5"
d="M.25 9.6c0-1.684 0-2.932.08-3.92.081-.985.24-1.69.547-2.29A5.75 5.75 0 0 1 3.39.877C3.99.57 4.695.41 5.68.33 6.668.25 7.916.25 9.6.25h4.8c1.684 0 2.932 0 3.92.08.985.081 1.69.24 2.29.547a5.75 5.75 0 0 1 2.513 2.513c.306.6.466 1.305.546 2.29.08.988.081 2.236.081 3.92v4.8c0 1.684 0 2.932-.08 3.92-.081.985-.24 1.69-.547 2.29a5.75 5.75 0 0 1-2.513 2.513c-.6.306-1.305.466-2.29.546-.988.08-2.236.081-3.92.081H9.6c-1.684 0-2.932 0-3.92-.08-.985-.081-1.69-.24-2.29-.547A5.75 5.75 0 0 1 .877 20.61C.57 20.01.41 19.305.33 18.32.25 17.332.25 16.084.25 14.4V9.6Zm11.044 10.17c.237.663 1.175.663 1.412 0l.628-1.753a7.75 7.75 0 0 1 4.683-4.683l1.753-.628c.663-.237.663-1.175 0-1.412l-1.753-.628a7.75 7.75 0 0 1-4.683-4.683l-.628-1.753c-.237-.663-1.175-.663-1.412 0l-.628 1.753a7.75 7.75 0 0 1-4.683 4.683l-1.753.628c-.663.237-.663 1.175 0 1.412l1.753.628a7.75 7.75 0 0 1 4.683 4.683l.628 1.753Z"
></path><defs
><radialGradient
id="a"
cx="0"
cy="0"
r="1"
gradientTransform="rotate(-40.136 32.164 11.75) scale(33.3542)"
gradientUnits="userSpaceOnUse"
><stop offset=".639" stop-color="#9818E7"></stop><stop offset="1" stop-color="#DF7F4F"
></stop></radialGradient
><linearGradient id="b" x1="12" x2="12" y1="0" y2="24" gradientUnits="userSpaceOnUse"
><stop stop-color="#fff"></stop><stop offset="1" stop-color="#fff" stop-opacity="0"
></stop></linearGradient
></defs
></svg
>
{SiteTitle}
</a>
</h2>
<div class="links">
<a href="mailto:contactus@yourwebsite.com">Contact</a>
</div>
</nav>
</header>

<style>
.links a {
text-decoration: none;
}
</style>
87 changes: 87 additions & 0 deletions examples/starlog/src/components/SEO.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
import type { ImageMetadata } from 'astro';
type Image = {
src: string | ImageMetadata;
alt: string;
};
type SEOMetadata = {
name: string;
title: string;
description: string;
image?: Image | undefined;
canonicalURL?: URL | string | undefined;
locale?: string;
};
type OpenGraph = Partial<SEOMetadata> & {
type?: string;
};
type Twitter = Partial<SEOMetadata> & {
handle?: string;
card?: 'summary' | 'summary_large_image';
};
export type Props = SEOMetadata & {
og?: OpenGraph;
twitter?: Twitter;
};
const {
name,
title,
description,
image,
locale = 'en',
canonicalURL = new URL(Astro.url.pathname, Astro.site),
} = Astro.props;
const og = {
name,
title,
description,
canonicalURL,
image,
locale,
type: 'website',
...(Astro.props.og ?? {}),
} satisfies OpenGraph;
const twitter = {
name,
title,
description,
canonicalURL,
image,
locale,
card: 'summary_large_image',
...Astro.props.twitter,
};
function normalizeImageUrl(image: string | ImageMetadata) {
return typeof image === 'string' ? image : image.src;
}
---

<!-- Page Metadata -->
<link rel="canonical" href={canonicalURL} />
<meta name="description" content={description} />

<!-- OpenGraph Tags -->
<meta property="og:title" content={og.title} />
<meta property="og:type" content={og.type} />
<meta property="og:url" content={canonicalURL} />
<meta property="og:locale" content={og.locale} />
<meta property="og:description" content={og.description} />
<meta property="og:site_name" content={og.name} />
{og.image && <meta property="og:image" content={normalizeImageUrl(og.image.src)} />}
{og.image && <meta property="og:image:alt" content={og.image.alt} />}

<!-- Twitter Tags -->
<meta name="twitter:card" content={twitter.card} />
<meta name="twitter:site" content={twitter.handle} />
<meta name="twitter:title" content={twitter.title} />
<meta name="twitter:description" content={twitter.description} />
{twitter.image && <meta name="twitter:image" content={normalizeImageUrl(twitter.image.src)} />}
{twitter.image && <meta name="twitter:image:alt" content={twitter.image.alt} />}
5 changes: 5 additions & 0 deletions examples/starlog/src/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place any global data in this file.
// You can import this data from anywhere in your site by using the `import` keyword.

export const SiteTitle = 'Starlog';
export const SiteDescription = 'Welcome to my website!';
19 changes: 19 additions & 0 deletions examples/starlog/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineCollection, z } from 'astro:content';

const releases = defineCollection({
// Type-check frontmatter using a schema
schema: ({ image }) =>
z.object({
title: z.string(),
description: z.string(),
versionNumber: z.string(),
image: z.object({
src: image(),
alt: z.string(),
}),
// Transform string to Date object
date: z.date({ coerce: true }),
}),
});

export const collections = { releases };
29 changes: 29 additions & 0 deletions examples/starlog/src/content/releases/1_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: 'Introducing Nebulous 1.0!'
date: '2022-03-21'
versionNumber: '1.0'
description: 'This is the first post of my new Astro blog.'
image:
src: '../../assets/starlog-placeholder-1.jpg'
alt: 'The full Astro logo.'
---

## A New World with 1.0

![Nebulous 2.0 Release](../../assets/starlog-placeholder-1.jpg)

Hey there, Nebulous users! We're back with some exciting updates that will turbocharge your Nebulous experience. Here's the lowdown:

### 🍿 New Features & Enhancements

- **NebulaProtect Supercharged:** Enjoy beefed-up security and real-time monitoring to keep your digital fortress unbreachable.
- **NebulaConnect for Teams:** Collaboration is a breeze with integrated project management tools.
- **Speed Boost Galore:** We've fine-tuned Nebulous for ultimate speed and responsiveness.

### 🐞 Bug Fixes

- Kicked pesky crashes out the door for NebulaSync.
- Fixed rare data hiccups during file transfers.
- Nebulous is now even friendly with older devices.

Thank you for making Nebulous your tech partner. We thrive on your feedback, so if you have ideas or run into bumps, don't hesitate to drop a line to our support wizards. Together, we're taking Nebulous to the next level!
Loading

0 comments on commit 2c6b96e

Please sign in to comment.