pass props.path down to nav - is a bit more self-explanatory

This commit is contained in:
Rich Harris
2018-06-28 14:34:06 -04:00
parent 365e8521ae
commit 1dcad25401
2 changed files with 4 additions and 9 deletions

View File

@@ -1,9 +1,4 @@
<Nav page={ <Nav path={props.path}/>
props.path === '/' ? 'home' :
props.path === '/about' ? 'about' :
props.path.startsWith('/blog') ? 'blog' :
null
}/>
<main> <main>
<svelte:component this={Page} {...props}/> <svelte:component this={Page} {...props}/>

View File

@@ -1,11 +1,11 @@
<nav> <nav>
<ul> <ul>
<li><a class='{page === "home" ? "selected" : ""}' href='.'>home</a></li> <li><a class='{path === "/" ? "selected" : ""}' href='.'>home</a></li>
<li><a class='{page === "about" ? "selected" : ""}' href='about'>about</a></li> <li><a class='{path === "/about" ? "selected" : ""}' href='about'>about</a></li>
<!-- for the blog link, we're using rel=prefetch so that Sapper prefetches <!-- for the blog link, we're using rel=prefetch so that Sapper prefetches
the blog data when we hover over the link or tap it on a touchscreen --> the blog data when we hover over the link or tap it on a touchscreen -->
<li><a rel=prefetch class='{page === "blog" ? "selected" : ""}' href='blog'>blog</a></li> <li><a rel=prefetch class='{path.startsWith("/blog") ? "selected" : ""}' href='blog'>blog</a></li>
</ul> </ul>
</nav> </nav>