Fix navigation segment parsing

This commit is contained in:
Michal Vanko 2021-04-24 18:57:13 +02:00
parent 58347b9ca6
commit 136585e554
2 changed files with 8 additions and 5 deletions

View File

@ -60,7 +60,7 @@
<section class="nav-main"> <section class="nav-main">
<ul> <ul>
<li> <li>
<a class={classNames({ selected: segment === undefined })} href="/"> <a class={classNames({ selected: segment === '/' })} href="/">
Introduction Introduction
</a> </a>
</li> </li>
@ -69,14 +69,14 @@
<li> <li>
<a <a
rel="prefetch" rel="prefetch"
class={classNames({ selected: segment === 'blog' })} class={classNames({ selected: segment.startsWith('/blog') })}
href="/blog"> href="/blog">
Blog Blog
</a> </a>
</li> </li>
<li> <li>
<a <a
class={classNames({ selected: segment === 'portfolio' })} class={classNames({ selected: segment.startsWith('/portfolio') })}
href="/portfolio"> href="/portfolio">
Portfolio Portfolio
</a> </a>
@ -91,6 +91,7 @@
</section> </section>
{#if segment === 'portfolio'} {#if segment === 'portfolio'}
<!-- Move to portfolio layout -->
<section class="page-navigation"> <section class="page-navigation">
<a href="portfolio#personal-information">About</a> <a href="portfolio#personal-information">About</a>
<a href="portfolio#skills">Skills</a> <a href="portfolio#skills">Skills</a>

View File

@ -1,11 +1,13 @@
<script context="module" lang="typescript"> <script context="module" lang="typescript">
import { take } from 'ramda' import { take } from 'ramda'
import type { LoadInput, LoadOutput } from '@sveltejs/kit/types/page';
export function load({ fetch }) { export function load({ fetch, page }: LoadInput): Promise<LoadOutput> {
return fetch(`/blog.json`) return fetch(`/blog.json`)
.then((r) => r.json()) .then((r) => r.json())
.then((posts) => { .then((posts) => {
return { props: { latestPosts: take(5, posts) }} console.log(page)
return { props: { latestPosts: take(5, posts), segment: page.path }}
}) })
} }
</script> </script>