mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-09 21:07:46 +00:00
changelog thingies
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export const prerender = false;
|
||||
@@ -1,15 +0,0 @@
|
||||
import { CHANGELOG_DEPENDENCY, getAllChangelogEntries } from './utils';
|
||||
|
||||
const PER_PAGE = 5;
|
||||
|
||||
export const load = async ({ depends, url }) => {
|
||||
depends(CHANGELOG_DEPENDENCY);
|
||||
|
||||
const page = parseInt(url.searchParams.get('page') || '1', 10);
|
||||
const entries = await getAllChangelogEntries();
|
||||
|
||||
return {
|
||||
entries: entries.slice(0, page * PER_PAGE),
|
||||
nextPage: page < Math.ceil(entries.length / PER_PAGE) ? page + 1 : null,
|
||||
};
|
||||
};
|
||||
@@ -3,7 +3,7 @@
|
||||
import { MainFooter, FooterNav, PreFooter } from '$lib/components';
|
||||
import { Main } from '$lib/layouts';
|
||||
import { DEFAULT_DESCRIPTION, DEFAULT_HOST } from '$lib/utils/metadata';
|
||||
import ChangelogEntry from './ChangelogEntry.svelte';
|
||||
import ChangelogEntry from '../ChangelogEntry.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
};
|
||||
|
||||
function loadMore() {
|
||||
goto(`/changelog/?page=${data.nextPage}`, { replaceState: true, noScroll: true });
|
||||
goto(`/changelog/${data.nextPage}`, { replaceState: true, noScroll: true });
|
||||
}
|
||||
</script>
|
||||
|
||||
25
src/routes/changelog/[[page]]/+page.ts
Normal file
25
src/routes/changelog/[[page]]/+page.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { CHANGELOG_DEPENDENCY, getAllChangelogEntries } from '../utils';
|
||||
|
||||
const PER_PAGE = 5;
|
||||
|
||||
export const entries = async () => {
|
||||
const entries = await getAllChangelogEntries();
|
||||
const totalPages = Math.ceil(entries.length / PER_PAGE);
|
||||
return Array.from({ length: totalPages }, (_, i) => {
|
||||
return {
|
||||
page: (i + 1).toString()
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
export const load = async ({ depends, params }) => {
|
||||
depends(CHANGELOG_DEPENDENCY);
|
||||
|
||||
const page = parseInt(params.page || '1', 10);
|
||||
const entries = await getAllChangelogEntries();
|
||||
|
||||
return {
|
||||
entries: entries.slice(0, page * PER_PAGE),
|
||||
nextPage: page < Math.ceil(entries.length / PER_PAGE) ? page + 1 : null
|
||||
};
|
||||
};
|
||||
@@ -40,7 +40,7 @@
|
||||
<header class="aw-main-article-header">
|
||||
<a class="aw-link aw-u-color-text-secondary" href="/changelog">
|
||||
<span class="aw-icon-chevron-left" aria-hidden="true" />
|
||||
<span>Back to changelog</span>
|
||||
<span>Back to Changelog</span>
|
||||
</a>
|
||||
<ul class="aw-metadata aw-caption-400">
|
||||
<li>
|
||||
@@ -1,5 +1,5 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { getAllChangelogEntries } from '../utils.js';
|
||||
import { getAllChangelogEntries } from '../../utils.js';
|
||||
import type { EntryGenerator } from './$types.js';
|
||||
|
||||
export const entries: EntryGenerator = async () => {
|
||||
@@ -11,7 +11,7 @@ export const getAllChangelogEntries = async () => {
|
||||
const typedComponent = component as ChangelogComponent;
|
||||
const { frontmatter } = typedComponent;
|
||||
const slug = filepath.replace(/\.markdoc$/, '').replace('(entries)/', '');
|
||||
const href = `/changelog/${slug}`;
|
||||
const href = `/changelog/entry/${slug}`;
|
||||
|
||||
return { ...frontmatter, component: typedComponent.default, filepath, href, slug };
|
||||
});
|
||||
|
||||
@@ -11,7 +11,8 @@ function absolute(path) {
|
||||
return join(dirname(fileURLToPath(import.meta.url)), path);
|
||||
}
|
||||
|
||||
const isVercel = process.env.VERCEL === '1';
|
||||
// const isVercel = process.env.VERCEL === '1';
|
||||
const isVercel = true;
|
||||
|
||||
const adapter = isVercel ? staticAdapter() : nodeAdapter();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user