Skip to content

Instantly share code, notes, and snippets.

@brutalzinn
Created April 26, 2021 13:49
Show Gist options
  • Save brutalzinn/efe0cc18350784fad60168ec0a45cc31 to your computer and use it in GitHub Desktop.
Save brutalzinn/efe0cc18350784fad60168ec0a45cc31 to your computer and use it in GitHub Desktop.
bootcamp title correction
const history = useHistory();
useEffect(() => {
return history.listen((location) => {
let nomeDaPagina="Nome do projeto"
let _title = location.pathname.replace('/', '')
_title = _title.indexOf('/') > 0 ? _title.substring(0, _title.indexOf('/')) : _title
switch(_title.toUpperCase()){
case '':
_title = `${nomeDaPagina}-Início`
break;
case 'CADASTRO':
_title = `${nomeDaPagina}-Cadastro`
break;
default: _title = 'Erro'
break;
}
document.title = _title;
console.log(`Você está na página ${location.pathname}`)
})
},[history])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment