Is it possible compage current url
with url resolved by resolve_url
plugin?
#464
-
I'm building layout with menu. And I want to highlight current page link. Links in menu resolving by // _includes/withHeader.tsx
export default ({lang, url}) => {
const isCurrentPage = url === `index.tsx(lang=${lang})` // 👈 how to compare current url and resolved url?
return <nav>
<a href={`index.tsx(lang=${lang})`} {...isCurrentPage ? {ariaCurrent: 'page'} : {}}>{goHome}</a>
</nav>
} |
Beta Was this translation helpful? Give feedback.
Answered by
oscarotero
Aug 3, 2023
Replies: 2 comments
-
Lume provides the You can do this: export default ({lang, url}, helpers) => {
const comparedUrl = helpers.url(`~/index.tsx(lang=${lang})`);
const isCurrentPage = url === comparedUrl
return <nav>
<a href={`index.tsx(lang=${lang})`} {...isCurrentPage ? {ariaCurrent: 'page'} : {}}>{goHome}</a>
</nav>
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
cawa-93
-
I see. I probably should use export default ({lang, url, page}) => {
const isCurrentPage = page.src.entry.name === `index.tsx`
return <nav>
<a href={`index.tsx(lang=${lang})`} {...isCurrentPage ? {ariaCurrent: 'page'} : {}}>{goHome}</a>
</nav>
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lume provides the
url
filter out of the box: https://lume.land/plugins/url/#url-filterYou can do this: