feat: Blog catalog and tags #7
|
@ -0,0 +1,11 @@
|
||||||
|
import type { Reroute } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
const translated: Record<string, string> = {
|
||||||
|
'/post': '/page/1',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const reroute: Reroute = ({ url }) => {
|
||||||
|
if (url.pathname in translated) {
|
||||||
|
return translated[url.pathname];
|
||||||
|
}
|
||||||
|
};
|
|
@ -35,7 +35,7 @@
|
||||||
<style>
|
<style>
|
||||||
#post-heading {
|
#post-heading {
|
||||||
@apply flex flex-col;
|
@apply flex flex-col;
|
||||||
width: 100%;
|
margin: .5em 1em .5em 1em;
|
||||||
}
|
}
|
||||||
#post-title {
|
#post-title {
|
||||||
@apply text-3xl;
|
@apply text-3xl;
|
||||||
|
|
|
@ -5,7 +5,7 @@ export async function getPosts() {
|
||||||
const allPosts = await Promise.all(
|
const allPosts = await Promise.all(
|
||||||
iterablePostFiles.map(async ([pathMarkdown, resolver]) => {
|
iterablePostFiles.map(async ([pathMarkdown, resolver]) => {
|
||||||
const { metadata } = await resolver();
|
const { metadata } = await resolver();
|
||||||
const pathPost = pathMarkdown.slice(pathMarkdown.lastIndexOf("/") + 1, -".md".length);
|
const pathPost = "/post/" + pathMarkdown.slice(pathMarkdown.lastIndexOf("/") + 1, -".md".length);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
import { routes } from "$lib/sitemap.ts"
|
import { routes } from "$lib/sitemap.ts"
|
||||||
|
|
||||||
function isCurrentLink(pathname, route) {
|
function isCurrentLink(pathname, route) {
|
||||||
return route != "/" && pathname.startsWith(route);
|
return route != "/" && pathname.startsWith(route)
|
||||||
|
|| route == "/post" && pathname.startsWith("/page");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,14 @@
|
||||||
<a
|
<a
|
||||||
class="nav-link icon"
|
class="nav-link icon"
|
||||||
class:disabled-link={disableLinkPrev}
|
class:disabled-link={disableLinkPrev}
|
||||||
href="/page/{pageN-1}"><ChevronLeft /></a>
|
href="/page/{Math.max(1, pageN-1)}"><ChevronLeft /></a>
|
||||||
<div id="page-map">
|
<div id="page-map">
|
||||||
<p id="page-num">{pageN}/{maxPageN}</p>
|
<p id="page-num">{pageN}/{maxPageN}</p>
|
||||||
</div>
|
</div>
|
||||||
<a
|
<a
|
||||||
class="nav-link icon"
|
class="nav-link icon"
|
||||||
class:disabled-link={disableLinkNext}
|
class:disabled-link={disableLinkNext}
|
||||||
href="/page/{pageN+1}"><ChevronRight /></a>
|
href="/page/{Math.min(maxPageN, pageN+1)}"><ChevronRight /></a>
|
||||||
<a
|
<a
|
||||||
class="nav-link icon"
|
class="nav-link icon"
|
||||||
class:disabled-link={disableLinkNext}
|
class:disabled-link={disableLinkNext}
|
||||||
|
@ -51,7 +51,8 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: horizontal;
|
flex-direction: horizontal;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 1em 6em 1em 6em;
|
margin: 1em auto 1em auto;
|
||||||
|
width: 80%;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
#page-map {
|
#page-map {
|
||||||
|
|
|
@ -40,6 +40,12 @@ const config = {
|
||||||
precompress: false,
|
precompress: false,
|
||||||
trailingSlash: 'always',
|
trailingSlash: 'always',
|
||||||
}),
|
}),
|
||||||
|
prerender: {
|
||||||
|
crawl: true,
|
||||||
|
entries: [
|
||||||
|
"/page/1/",
|
||||||
|
],
|
||||||
|
},
|
||||||
alias: {
|
alias: {
|
||||||
$content: contentDir,
|
$content: contentDir,
|
||||||
"@/*": "./*",
|
"@/*": "./*",
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
test('Navigate to blog post', async ({ page }) => {
|
||||||
|
await page.goto('/post');
|
||||||
|
await page.getByText('The Perfect Math Class').click();
|
||||||
|
await expect(page).toHaveURL("/post/the-perfect-math-class/");
|
||||||
|
});
|
Loading…
Reference in New Issue