So, I just noticed this strange behavior, I must be missing something. I've created a local bike rental website. When I'm on the homepage the navigation works perfectly, but let's say I visit the services page and I would like to go to the bike repair page, the bike repair page is appended tot the services page.
Expected behavior: "example.com/bike-repair"
Current behavior: "example.com/services/bike-repair"
It looks like the LinkResolver somehow appends the current page to the url, this is unexpected. Does this look familiar to anyone?
./utils/linkResolver.js
const linkResolver = (doc) => {
if (doc.type === 'page') {
return `../${doc.uid}`
}
return '/'
}
module.exports = linkResolver
./components/NavigationServices.js
const Services = () => {
return (
<StaticQuery
query={`${servicesQuery}`}
render={(data) => {
const prismicContent = data.allPrismicNavigationServices.edges[0]
if (!prismicContent) return null
const doc = prismicContent.node
return(
<ServicesLinks>
<ServicesListHeading>
Services
</ServicesListHeading>
<ServicesList as="ul">
{doc.data.services_navigation.map((navItem, index) => {
return (
<li className="nav-item" key={`link-${index}`}>
<NavLink to={navItem.link.uid}>
{navItem.link_label[0].text}
</NavLink>
</li>
)
})}
</ServicesList>
</ServicesLinks>
)
}}
/>
)
}
const servicesQuery = graphql`
query servicesQuery {
allPrismicNavigationServices {
edges {
node {
data {
services_navigation {
link {
type
uid
}
link_label {
text
}
}
}
}
}
}
}
`
export default Services
With best regards,
Kevin