feat: Blog catalog and tags #7

Merged
aniva merged 11 commits from post/page into main 2024-10-10 14:49:18 -07:00
6 changed files with 48 additions and 30 deletions
Showing only changes of commit d1cc88397b - Show all commits

View File

@ -1,6 +1,7 @@
export const routes: { route: string, name: string, inactive?: boolean }[] = [ export const routes: { route: string, name: string, disabled?: boolean }[] = [
{ route: "/", name: "Home" }, { route: "/", name: "Home" },
{ route: "/post", name: "Blog" }, { route: "/post", name: "Blog" },
{ route: "/art", name: "Art", inactive: true }, { route: "/tag", name: "Tags", disabled: true },
{ route: "/gallery", name: "Gallery", disabled: true },
{ route: "/archives", name: "Archives" }, { route: "/archives", name: "Archives" },
]; ];

View File

@ -36,8 +36,9 @@
font-weight: 500; font-weight: 500;
font-family: serif; font-family: serif;
} }
:global(p.nav-link) { :global(a.disabled-link) {
color: rgb(128,128,128); color: rgb(128,128,128);
pointer-events: none;
} }
:global(a) { :global(a) {
color: theme('colors.eucalyptus.400'); color: theme('colors.eucalyptus.400');
@ -72,7 +73,7 @@
} }
} }
} }
:global(a.active-link) { :global(a.current-link) {
color: theme('colors.magenta.500'); color: theme('colors.magenta.500');
&::after { &::after {

View File

@ -53,11 +53,7 @@
{#each routes as item} {#each routes as item}
{#if item.route !== "/"} {#if item.route !== "/"}
<Separator class="bg-gray-500 dark:bg-gray-100" orientation="vertical" /> <Separator class="bg-gray-500 dark:bg-gray-100" orientation="vertical" />
{#if item.inactive ?? false} <a class="navbar-link" href={item.route} class:disabled-link={item.disabled}>{item.name}</a>
<p class="navbar-link">{item.name}</p>
{:else}
<a class="navbar-link" href={item.route}>{item.name}</a>
{/if}
{/if} {/if}
{/each} {/each}
</div> </div>

View File

@ -2,21 +2,18 @@
import { page } from '$app/stores'; import { page } from '$app/stores';
import { routes } from "$lib/sitemap.ts" import { routes } from "$lib/sitemap.ts"
function isActiveLink(pathname, route) { function isCurrentLink(pathname, route) {
return route != "/" && pathname.startsWith(route); return route != "/" && pathname.startsWith(route);
} }
</script> </script>
<div id="navbar" class="h-5 space-x-4"> <div id="navbar" class="h-5 space-x-4">
{#each routes as item} {#each routes as item}
{#if item.inactive ?? false} <a
<p class="nav-link" class="nav-link"
>{item.name}</p> class:current-link={isCurrentLink($page.url.pathname, item.route)}
{:else} class:disabled-link={item.disabled}
<a class="nav-link" href={item.route}>{item.name}</a>
class:active-link={isActiveLink($page.url.pathname, item.route)}
href={item.route}>{item.name}</a>
{/if}
{/each} {/each}
</div> </div>

View File

@ -4,8 +4,11 @@
const { posts, pageN, maxPageN } = data; const { posts, pageN, maxPageN } = data;
import siteMetadata from '$content/metadata.json'; import siteMetadata from '$content/metadata.json';
import { DoubleArrowLeft, DoubleArrowRight, ChevronLeft, ChevronRight, DotsHorizontal } from 'svelte-radix'; import { DoubleArrowLeft, DoubleArrowRight, ChevronLeft, ChevronRight } from 'svelte-radix';
import PostHeader from '$lib/components/PostHeader.svelte'; import PostHeader from '$lib/components/PostHeader.svelte';
const disableLinkPrev = pageN == 1;
const disableLinkNext = pageN == maxPageN;
</script> </script>
<svelte:head> <svelte:head>
@ -21,20 +24,40 @@
{/each} {/each}
</ul> </ul>
<hr class="separator" /> <hr class="separator" />
<div id="pagenum"> <div id="page-navigator">
<a class="nav-link icon" href="/page/1"><DoubleArrowLeft /></a> <a
<a class="nav-link icon" href="/page/{pageN-1}"><ChevronLeft /></a> class="nav-link icon"
<p class="nav-link icon"><DotsHorizontal/></p> class:disabled-link={disableLinkPrev}
<a class="nav-link icon" href="/page/{pageN+1}"><ChevronRight /></a> href="/page/1"><DoubleArrowLeft /></a>
<a class="nav-link icon" href="/page/{maxPageN}"><DoubleArrowRight /></a> <a
class="nav-link icon"
class:disabled-link={disableLinkPrev}
href="/page/{pageN-1}"><ChevronLeft /></a>
<div id="page-map">
<p id="page-num">{pageN}/{maxPageN}</p>
</div>
<a
class="nav-link icon"
class:disabled-link={disableLinkNext}
href="/page/{pageN+1}"><ChevronRight /></a>
<a
class="nav-link icon"
class:disabled-link={disableLinkNext}
href="/page/{maxPageN}"><DoubleArrowRight /></a>
</div> </div>
<style> <style>
#pagenum { #page-navigator {
display: flex; display: flex;
flex-direction: horizontal; flex-direction: horizontal;
justify-content: space-between; justify-content: space-between;
margin-left: 6em; margin: 1em 6em 1em 6em;
margin-right: 6em; align-items: center;
}
#page-map {
display: inline-block;
}
#page-num {
color: rgb(128,128,128);
} }
</style> </style>

View File

@ -3,14 +3,14 @@
export let data: PageData; export let data: PageData;
const { metadata, Content } = data; const { metadata, Content } = data;
import siteMetadata from '$content/metadata.json'; import siteMetadata from '$content/metadata.json';
import Heading from '../Heading.svelte'; import PostHeader from '$lib/components/PostHeader.svelte';
</script> </script>
<svelte:head> <svelte:head>
<title>{metadata.title} | {siteMetadata.blogName}</title> <title>{metadata.title} | {siteMetadata.blogName}</title>
</svelte:head> </svelte:head>
<Heading metadata={metadata}/> <PostHeader metadata={metadata}/>
<hr /> <hr />
<article class="prose lg:prose-xl dark:prose-invert p-4"> <article class="prose lg:prose-xl dark:prose-invert p-4">