docs: add dynamic href to cta

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10417
GitOrigin-RevId: eb92c66e777050457374968d45544d1dbb7c000d
This commit is contained in:
Rob Dominguez 2023-10-27 03:57:34 -05:00 committed by hasura-bot
parent b2eed614fa
commit faf2636172
2 changed files with 18 additions and 1 deletions

View File

@ -249,7 +249,7 @@ const config = {
className: 'nav-link_login',
},
{
to: 'https://cloud.hasura.io/signup?pg=products&plcmt=header&cta=try-hasura&tech=default',
to: 'https://cloud.hasura.io/signup?pg=products&plcmt=header&cta=get_started&tech=default',
label: 'Get Started',
position: 'right',
className: 'nav-link_getting-started',

View File

@ -33,6 +33,23 @@ const CustomDocItem = props => {
cell.innerHTML = cell.innerHTML.replace(/_/g, '_<wbr>');
});
}
// dynamically updating the pg prop for the getting started cta
function updateGettingStartedParam() {
const linkElement = document.querySelector('.navbar__link.nav-link_getting-started');
if (linkElement) {
let page = props.location.pathname;
page = page.slice(0, -1);
page = page.replace('/docs/', 'docs_v2_').replace('latest/', '').replace(/\//g, '_');
const href = linkElement.getAttribute('href');
const newHref = href.replace(/pg=[a-z_-]+/, `pg=${page}`);
linkElement.setAttribute('href', newHref);
}
}
updateGettingStartedParam();
}, []);
// redirect them to the index if they attempt to directly navigate to a path with