Skip to content

Instantly share code, notes, and snippets.

@nafeu
Created February 10, 2021 14:45
Show Gist options
  • Select an option

  • Save nafeu/8a5466455574099c6a33ac1aafae56b6 to your computer and use it in GitHub Desktop.

Select an option

Save nafeu/8a5466455574099c6a33ac1aafae56b6 to your computer and use it in GitHub Desktop.
const getNavigation = (currentPath: string) => `
<div id="nav">
${pages.map(({ path, name }) => {
const href = path === HOME_PATH ? '/' : path;
const isSelectedPage = path === currentPath;
const classes = `nav-item ${isSelectedPage ? 'selected': ''}`;
return `<a class="${classes}" href=${href}>${name}</a>`;
}).join('\n')}
</div>
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment