generated from avior/template-web-astro
feat: Add first version of website
Signed-off-by: Avior <github@avior.me>
This commit is contained in:
@ -1,13 +1,24 @@
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro'
|
||||
import { getCollection } from 'astro:content'
|
||||
import Breadcrumb from 'components/global/Breadcrumb.astro'
|
||||
import { Image } from 'astro:assets'
|
||||
|
||||
const projects = await getCollection('projects')
|
||||
---
|
||||
|
||||
<Layout title="Welcome to Astro.">
|
||||
<main>
|
||||
<h1>Welcome to <span class="text-gradient">Astro</span></h1>
|
||||
<p class="instructions">
|
||||
To get started, open the directory <code>src/pages</code> in your project.<br />
|
||||
<strong>Code Challenge:</strong> Tweak the "Welcome to Astro" message above.
|
||||
</p>
|
||||
</main>
|
||||
<Layout title="Avior.me - Developpement de solutions selon vos besoins">
|
||||
<div class="container">
|
||||
<Breadcrumb items={[{ text: 'Accueil', href: '/' }, { text: 'Projets' }]} />
|
||||
<main class="grid grid-cols-3 gap-4">
|
||||
{projects.map((it) => (
|
||||
<a href={`/projets/${it.slug}`} class="flex flex-col gap-4">
|
||||
{it.data.image && (
|
||||
<Image src={it.data.image} alt="" />
|
||||
)}
|
||||
<p>{it.data.title}</p>
|
||||
</a>
|
||||
))}
|
||||
</main>
|
||||
</div>
|
||||
</Layout>
|
||||
|
26
src/pages/projets/[project].astro
Normal file
26
src/pages/projets/[project].astro
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
import { getCollection } from 'astro:content';
|
||||
import Article from 'layouts/Article.astro'
|
||||
|
||||
export const prerender = true
|
||||
// 1. Generate a new path for every collection entry
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection('projects');
|
||||
return blogEntries.map(entry => ({
|
||||
params: { project: entry.slug }, props: { entry },
|
||||
}));
|
||||
}
|
||||
// 2. For your template, you can get the entry directly from the prop
|
||||
const { entry } = Astro.props;
|
||||
const { Content } = await entry.render();
|
||||
---
|
||||
<Article title={entry.data.title} link={entry.data.link} breadcrumb={[{text: 'Accueil', href: '/'}, {text: 'Projets', href: '/projets'}, {text: entry.data.title}]}>
|
||||
<h1>{entry.data.title}</h1>
|
||||
<p class="flex justify-end font-lights my-0">
|
||||
<span>Sortie initial le {entry.data.created.toLocaleDateString('fr')}</span>
|
||||
<!-- <p>Software updated: {entry.data.updated.toLocaleDateString()}</p> -->
|
||||
</p>
|
||||
|
||||
<Content />
|
||||
|
||||
</Article>
|
23
src/pages/projets/index.astro
Normal file
23
src/pages/projets/index.astro
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
import { getCollection } from 'astro:content'
|
||||
import { Image } from 'astro:assets'
|
||||
import Layout from 'layouts/Layout.astro'
|
||||
import Breadcrumb from 'components/global/Breadcrumb.astro'
|
||||
const entries = await getCollection('projects')
|
||||
---
|
||||
|
||||
<Layout title='pouet'>
|
||||
<div class="container">
|
||||
<Breadcrumb items={[{ text: 'Accueil', href: '/' }, { text: 'Projets' }]} />
|
||||
<main class="grid grid-cols-3 gap-4">
|
||||
{entries.map((it) => (
|
||||
<a href={`/projets/${it.slug}`} class="flex flex-col gap-4">
|
||||
{it.data.image && (
|
||||
<Image src={it.data.image} alt="" />
|
||||
)}
|
||||
<p>{it.data.title}</p>
|
||||
</a>
|
||||
))}
|
||||
</main>
|
||||
</div>
|
||||
</Layout>
|
29
src/pages/sitemap.xml.ts
Normal file
29
src/pages/sitemap.xml.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import type { APIRoute } from 'astro'
|
||||
import { getCollection } from 'astro:content'
|
||||
import Sitemap from 'easy-sitemap'
|
||||
|
||||
const projects = await getCollection('projects')
|
||||
|
||||
|
||||
/**
|
||||
* sitemap generation
|
||||
*/
|
||||
export const ALL: APIRoute = async () => {
|
||||
const sitemap = new Sitemap('https://avior.me')
|
||||
sitemap.addEntry('/', {
|
||||
priority: 1
|
||||
})
|
||||
sitemap.addEntry('/projets/', {
|
||||
priority: 0.5
|
||||
})
|
||||
for (const project of projects) {
|
||||
sitemap.addEntry('/projets/' + project.slug, {
|
||||
priority: 0.7
|
||||
})
|
||||
}
|
||||
return new Response(sitemap.build(), {
|
||||
headers: {
|
||||
'Content-Type': 'application/xml'
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user