use segment

This commit is contained in:
Rich Harris
2018-07-18 11:45:29 -04:00
parent 64837ca8a6
commit 0dc9fabf37
2 changed files with 4 additions and 4 deletions

View File

@@ -1,11 +1,11 @@
<nav> <nav>
<ul> <ul>
<li><a class='{path === "/" ? "selected" : ""}' href='.'>home</a></li> <li><a class='{segment === undefined ? "selected" : ""}' href='.'>home</a></li>
<li><a class='{path === "/about" ? "selected" : ""}' href='about'>about</a></li> <li><a class='{segment === "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='{path.startsWith("/blog") ? "selected" : ""}' href='blog'>blog</a></li> <li><a rel=prefetch class='{segment === "blog" ? "selected" : ""}' href='blog'>blog</a></li>
</ul> </ul>
</nav> </nav>

View File

@@ -1,4 +1,4 @@
<Nav {path}/> <Nav segment={child.segment}/>
<main> <main>
<svelte:component this={child.component} {...child.props}/> <svelte:component this={child.component} {...child.props}/>