feat: add examples

This commit is contained in:
Oliver Davies 2023-01-08 23:36:25 +00:00
parent 5e2309ee08
commit fab4519724
9 changed files with 205 additions and 14 deletions

14
src/components/Link.astro Normal file
View file

@ -0,0 +1,14 @@
---
interface Props {
name: string;
}
const { name } = Astro.props;
---
<a
class="py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current"
href="#0"
>
{name}
</a>

15
src/layouts/Layout.astro Normal file
View file

@ -0,0 +1,15 @@
---
---
<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>Astro</title>
</head>
<body class="p-10">
<slot />
</body>
</html>

View file

@ -0,0 +1,22 @@
---
import Layout from "~/layouts/Layout.astro";
---
<Layout>
<ul
class="flex flex-col justify-center gap-4 sm:flex-row sm:flex-wrap sm:gap-6"
>
<li><a class="link" href="#0">About</a></li>
<li><a class="link" href="#0">Blog</a></li>
<li><a class="link" href="#0">Talks</a></li>
<li><a class="link" href="#0">Daily list</a></li>
<li><a class="link" href="#0">Search</a></li>
<li><a class="link" href="#0">About</a></li>
</ul>
</Layout>
<style>
.link {
@apply py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current;
}
</style>

View file

@ -0,0 +1,16 @@
---
import Layout from "~/layouts/Layout.astro";
import Link from "~/components/Link.astro";
---
<Layout>
<ul
class="flex flex-col justify-center gap-4 sm:flex-row sm:flex-wrap sm:gap-6"
>
<li><Link name="About" /></li>
<li><Link name="Blog" /></li>
<li><Link name="Talks" /></li>
<li><Link name="Daily list" /></li>
<li><Link name="Search" /></li>
</ul>
</Layout>

View file

@ -1,15 +1,51 @@
---
import Layout from "~/layouts/Layout.astro";
---
<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>Astro</title>
</head>
<body>
<h1>Astro</h1>
</body>
</html>
<Layout>
<ul
class="flex flex-col justify-center gap-4 sm:flex-row sm:flex-wrap sm:gap-6"
>
<li>
<a
class="py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current"
href="#0">About</a
>
</li>
<li>
<a
class="py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current"
href="#0">Blog</a
>
</li>
<li>
<a
class="py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current"
href="#0">Talks</a
>
</li>
<li>
<a
class="py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current"
href="#0">Daily list</a
>
</li>
<li>
<a
class="py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current"
href="#0">Search</a
>
</li>
<li>
<a
class="py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current"
href="#0">About</a
>
</li>
</ul>
</Layout>

View file

@ -0,0 +1,30 @@
---
import Layout from "~/layouts/Layout.astro";
import Link from "~/components/Link.astro";
type LinkItem = {
name: string;
};
const links: LinkItem[] = [
{ name: "About" },
{ name: "Blog" },
{ name: "Talks" },
{ name: "Daily list" },
{ name: "Search" },
];
---
<Layout>
<ul
class="flex flex-col justify-center gap-4 sm:flex-row sm:flex-wrap sm:gap-6"
>
{
links.map(link => (
<li>
<Link name={link.name} />
</li>
))
}
</ul>
</Layout>

34
src/pages/loops.astro Normal file
View file

@ -0,0 +1,34 @@
---
import Layout from "~/layouts/Layout.astro";
type LinkItem = {
name: string;
};
const links: LinkItem[] = [
{ name: "About" },
{ name: "Blog" },
{ name: "Talks" },
{ name: "Daily list" },
{ name: "Search" },
];
---
<Layout>
<ul
class="flex flex-col justify-center gap-4 sm:flex-row sm:flex-wrap sm:gap-6"
>
{
links.map(link => (
<li>
<a
class="py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current"
href="#0"
>
{link.name}
</a>
</li>
))
}
</ul>
</Layout>

18
src/pages/variables.astro Normal file
View file

@ -0,0 +1,18 @@
---
import Layout from "~/layouts/Layout.astro";
const linkClasses =
"py-2 block border-b-2 border-transparent hover:border-blue-500 hover:text-blue-500 focus:outline-none focus:bg-yellow-400 focus:border-current";
---
<Layout>
<ul
class="flex flex-col justify-center gap-4 sm:flex-row sm:flex-wrap sm:gap-6"
>
<li><a class={linkClasses} href="#0">About</a></li>
<li><a class={linkClasses} href="#0">Blog</a></li>
<li><a class={linkClasses} href="#0">Talks</a></li>
<li><a class={linkClasses} href="#0">Daily list</a></li>
<li><a class={linkClasses} href="#0">Search</a></li>
</ul>
</Layout>

View file

@ -1,3 +1,9 @@
{
"extends": "astro/tsconfigs/strict"
}
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["src/*"],
}
}
}