-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds route support for remix and astro, fixes others
- Loading branch information
Showing
54 changed files
with
4,550 additions
and
4,918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Astro Demo application for Vercel Speed-insights | ||
|
||
## Setup | ||
|
||
This application was created with the following commands: | ||
|
||
- `cd apps` | ||
- `pnpm create astro@latest astro` (answers: empty, no to all) | ||
- `cd astro` | ||
- manually edit package.json to add `"@vercel/analytics": "workspace:*"` dependency | ||
- `pnpm i` | ||
|
||
Then we've added: | ||
|
||
1. a simple collection of Markdown blog posts in `src/contents/blog` folder | ||
2. a blog post page in `src/pages/blog/[...slug].astro` | ||
3. an index page in `src/pages/index.astro` which list all available blog posts | ||
4. a layout in `src/components/Base.astro`, used in both page, which includes our Analytics.astro component: | ||
|
||
```astro | ||
--- | ||
import Analytics from '@vercel/analytics/astro'; | ||
--- | ||
<html lang="en"> | ||
<head> | ||
<!-- ...--> | ||
<Analytics /> | ||
</head> | ||
<body> | ||
<slot /> | ||
</body> | ||
</html> | ||
``` | ||
|
||
## Usage | ||
|
||
Start it with `pnpm -F nuxt dev` and browse to [http://localhost:4321](http://localhost:4321) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { defineConfig } from 'astro/config'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "astro", | ||
"version": "0.0.1", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"astro": "astro", | ||
"build": "astro build", | ||
"dev": "astro dev", | ||
"preview": "astro preview", | ||
"start": "astro dev" | ||
}, | ||
"dependencies": { | ||
"@vercel/analytics": "workspace:*", | ||
"astro": "latest" | ||
}, | ||
"devDependencies": { | ||
"@astrojs/check": "^0.5.4", | ||
"@vercel/analytics": "workspace:*", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
import Analytics from '@vercel/analytics/astro'; | ||
--- | ||
<Analytics /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: About Bruno | ||
slug: bruno | ||
--- | ||
|
||
We don't talk about Bruno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: About Henry | ||
slug: henry | ||
--- | ||
|
||
Henry is a gentleman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../.astro/types.d.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
import Analytics from '@vercel/analytics/astro'; | ||
const { title } = Astro.props; | ||
--- | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta name="generator" content={Astro.generator} /> | ||
<title>{title}</title> | ||
<Analytics /> | ||
</head> | ||
<body> | ||
<slot /> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
import { getCollection } from 'astro:content'; | ||
import Layout from '../../layouts/Base.astro'; | ||
export async function getStaticPaths() { | ||
const blogEntries = await getCollection('blog'); | ||
return blogEntries.map(entry => ({ | ||
params: { slug: entry.slug }, props: { entry }, | ||
})); | ||
} | ||
const { entry } = Astro.props; | ||
const { Content } = await entry.render(); | ||
--- | ||
<Layout title={entry.data.title}> | ||
<Content /> | ||
<p><a href="/">back</a></p> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
import { getCollection } from 'astro:content'; | ||
import Layout from '../layouts/Base.astro'; | ||
const blogEntries = await getCollection('blog'); | ||
--- | ||
<Layout title="Astro"> | ||
<h1>Welcome to Astro</h1> | ||
<ul> | ||
{blogEntries.map(blogPostEntry => ( | ||
<li> | ||
<a href={`/blog/${blogPostEntry.slug}`}>{blogPostEntry.data.title}</a> | ||
</li> | ||
))} | ||
</ul> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "astro/tsconfigs/base", | ||
"compilerOptions": { | ||
"strictNullChecks": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Link from 'next/link'; | ||
|
||
export default async function BlogPage({ | ||
params, | ||
}: { | ||
params: Promise<{ slug: string }>; | ||
}) { | ||
const { slug } = await params; | ||
return ( | ||
<div> | ||
<h2>{slug}</h2> | ||
|
||
<Link href="/blog">Back to blog</Link> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Link from 'next/link'; | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<div> | ||
<Link href="/blog/my-first-blogpost">My first blog post</Link> | ||
<Link href="/blog/new-feature-release">Feature just got released</Link> | ||
<br /> | ||
<div>{children}</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Blog() { | ||
return <div>Welcome to the blog</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export default function Blog() { | ||
return <div>Welcome on the blog</div>; | ||
return <div>Welcome to the app-router blog</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function BlogPage() { | ||
return ( | ||
<div> | ||
<h1>Blog Page</h1> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
import Link from 'next/link'; | ||
|
||
export default function Page() { | ||
return null; | ||
return ( | ||
<> | ||
<div>Testing web analytics</div> | ||
<ul> | ||
<li> | ||
<Link href="/blog-pages/page-a">Pages directory A</Link> | ||
</li> | ||
<li> | ||
<Link href="/blog-pages/page-b">Pages directory B</Link> | ||
</li> | ||
<li> | ||
<Link href="/blog">App directory</Link> | ||
</li> | ||
</ul> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @type {import('eslint').Linter.Config} */ | ||
module.exports = { | ||
extends: ['@remix-run/eslint-config', '@remix-run/eslint-config/node'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ node_modules | |
/build | ||
/public/build | ||
.env | ||
|
||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { json, type LoaderFunctionArgs } from '@remix-run/node'; | ||
import { Link, useLoaderData } from '@remix-run/react'; | ||
import { track } from '@vercel/analytics'; | ||
|
||
export const loader = async ({ params }: LoaderFunctionArgs) => { | ||
return json({ slug: params.slug }); | ||
}; | ||
|
||
export default function BlogPage() { | ||
const { slug } = useLoaderData<typeof loader>(); | ||
return ( | ||
<div> | ||
<h1>Blog</h1> | ||
<p>We don't talk about {slug}</p> | ||
<br /> | ||
<Link to="/">Back</Link> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.