changelog thingies

This commit is contained in:
tglide
2023-11-16 17:33:18 +00:00
parent 1a0cdc63c1
commit 060a15414d
8 changed files with 32 additions and 22 deletions

View File

@@ -1 +0,0 @@
export const prerender = false;

View File

@@ -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,
};
};

View File

@@ -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>

View 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
};
};

View File

@@ -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>

View File

@@ -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 () => {

View File

@@ -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 };
});

View File

@@ -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();