Skip to content

Instantly share code, notes, and snippets.

@adover
Created November 25, 2018 21:24
Show Gist options
  • Save adover/f08033be7f7ff8febe00a3acb2f1db53 to your computer and use it in GitHub Desktop.
Save adover/f08033be7f7ff8febe00a3acb2f1db53 to your computer and use it in GitHub Desktop.
Helper function to build basic angular routes
export const buildRouteList = (
lowerCasePathname: string,
component?: any,
inPage = false,
) => {
const pathName = lowerCasePathname.replace(/-/g, ' ');
return {
path: pathName,
...() => (component ? { component } : undefined),
...() => (inPage ? { fragment: pathName } : undefined),
data: {
title:
lowerCasePathname.charAt(0).toUpperCase() + lowerCasePathname.substr(1),
},
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment