Skip to content

Commit

Permalink
Dynamically fill in document title, leave the default one in index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
user890104 committed Jun 8, 2024
1 parent 0340ed8 commit d1b7e1d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
TITLE=
BACKEND_URL=
DEVICE_BACKEND_URL=
MQTT_BACKEND_URL=
Expand Down
1 change: 0 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
TITLE=init Lab Space
BACKEND_URL=http://localhost:3000/
DEVICE_BACKEND_URL=http://localhost:4000/
MQTT_BACKEND_URL=https://mqtt.initlab.org/
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
cmd: build
env:
OAUTH_CLIENT_ID: ERBrlPWjf98L_nI8Moxr7Aqjy4no1eRU-zSOROc2RbU
TITLE: init Lab Space

- name: Upload production-ready build files
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="#2196f3" name="theme-color" />
<meta content="#2196f3" name="msapplication-navbutton-color" />
<title>%TITLE%</title>
<title>init Lab Space</title>
</head>
<body>
<div id="root"></div>
Expand Down
10 changes: 10 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ import Login from './pages/Login.jsx';
import { RequireLoggedIn } from './widgets/Route/RequireLoggedIn.jsx';
import ActionLog from './pages/ActionLog.jsx';
import Lights from './pages/Lights.jsx';
import { useVariant } from './hooks/useVariant.js';
import { useEffect } from 'react';

function App() {
const variant = useVariant();

useEffect(() => {
if (variant === 'colibri') {
document.title = 'Casa Libri';
}
}, [variant]);

return (<>
<NavBar />
<main>
Expand Down
1 change: 0 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default defineConfig({
sourcemap: true,
},
envPrefix: [
'TITLE',
'BACKEND_URL',
'DEVICE_BACKEND_URL',
'MQTT_BACKEND_URL',
Expand Down

0 comments on commit d1b7e1d

Please sign in to comment.