Adding Astrojs sources.
This commit is contained in:
parent
2664e6d8fc
commit
e20f4f45de
169 changed files with 11389 additions and 0 deletions
36
src/pages/[...page].astro
Normal file
36
src/pages/[...page].astro
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
import Notes from '../components/Notes.astro';
|
||||
import { type CollectionEntry, getCollection } from 'astro:content';
|
||||
|
||||
const base = import.meta.env.BASE_URL;
|
||||
|
||||
/*export async function getStaticPaths({ paginate }) {
|
||||
return paginate(notes.map((note: CollectionEntry<'notes'>) => ({
|
||||
params: { id: note.id },
|
||||
props: { note },
|
||||
})), {pageSize: 6});
|
||||
}*/
|
||||
|
||||
export async function getStaticPaths({ paginate }) {
|
||||
const notes = (await getCollection('notes')).sort(
|
||||
(a: CollectionEntry<'notes'>, b: CollectionEntry<'notes'>) => b.data.date.valueOf() - a.data.date.valueOf(),
|
||||
);
|
||||
return paginate(notes, { pageSize: 6 });
|
||||
};
|
||||
|
||||
const { page } = Astro.props;
|
||||
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<Notes notes={page.data} />
|
||||
<nav id="pagination">
|
||||
<ul>
|
||||
{page.url.first ? <li><a href={page.url.first}>« First</a></li> : <li><a class="disabled">« First</a></li>}
|
||||
{page.url.prev ? <li><a href={page.url.prev}>‹ Previous</a></li> : <li><a class="disabled">‹ Previous</a></li>}
|
||||
{page.url.next ? <li><a href={page.url.next}>Next ›</a></li> : <li><a class="disabled">Next ›</a></li>}
|
||||
{page.url.last ? <li><a href={page.url.last}>Last »</a></li> : <li><a class="disabled">Last »</a></li>}
|
||||
</ul>
|
||||
</nav>
|
||||
</Layout>
|
||||
Loading…
Reference in a new issue