Skip to content

Commit 9575d01

Browse files
committed
Dynamically change title
1 parent c18eafa commit 9575d01

File tree

6 files changed

+45
-39
lines changed

6 files changed

+45
-39
lines changed

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
"@types/qrcode": "^1.4.1",
175175
"@types/react": "^16.9.44",
176176
"@types/react-dom": "^16.9.9",
177+
"@types/react-helmet": "^6.1.2",
177178
"@types/react-router-dom": "^5.1.6",
178179
"@types/react-test-renderer": "^16.9.3",
179180
"@types/webpack-env": "^1.15.2",
@@ -260,6 +261,7 @@
260261
"qrcode": "^1.4.4",
261262
"react": "^17.0.1",
262263
"react-dom": "^17.0.1",
264+
"react-helmet": "^6.1.0",
263265
"react-router-dom": "^5.2.0",
264266
"regenerator-runtime": "^0.13.5",
265267
"source-map-support": "^0.5.19",

src/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function App() {
1515
<Switch>
1616
<Route path="/" component={Main} />
1717
</Switch>
18-
<Redirect from="*" to="/unix" />
18+
<Redirect from="*" to="/unix-converter" />
1919
</Router>
2020
);
2121
}

src/components/Main.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import { NavLink, Route } from 'react-router-dom';
33
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4+
import { Helmet } from 'react-helmet';
5+
46
import MarkdownToHtml from './markdown/MarkdownToHtml';
57
import UnixTimestamp from './timestamp/UnixTimestamp';
68
import HtmlPreview from './html/HtmlPreview';
@@ -83,9 +85,12 @@ const Main = () => {
8385
{/* Main content */}
8486
<section className="relative flex flex-col w-full bg-gray-200">
8587
<div className="h-full overflow-x-hidden overflow-y-auto px-6 my-6">
86-
{routes.map(({ path, Component }) => (
88+
{routes.map(({ path, name, Component }) => (
8789
<Route key={path} exact path={path}>
8890
<Component />
91+
<Helmet>
92+
<title>{name}</title>
93+
</Helmet>
8994
</Route>
9095
))}
9196
</div>

src/menu.ts

+8-36
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,15 @@ export default class MenuBuilder {
155155
label: 'Help',
156156
submenu: [
157157
{
158-
label: 'Learn More',
158+
label: 'Home Page',
159159
click() {
160-
shell.openExternal('https://electronjs.org');
160+
shell.openExternal('https://plainbelt.github.io');
161161
},
162162
},
163163
{
164-
label: 'Documentation',
164+
label: 'GitHub',
165165
click() {
166-
shell.openExternal(
167-
'https://github.com/electron/electron/tree/master/docs#readme'
168-
);
169-
},
170-
},
171-
{
172-
label: 'Community Discussions',
173-
click() {
174-
shell.openExternal('https://www.electronjs.org/community');
175-
},
176-
},
177-
{
178-
label: 'Search Issues',
179-
click() {
180-
shell.openExternal('https://github.com/electron/electron/issues');
166+
shell.openExternal('https://github.com/plainbelt/plainbelt');
181167
},
182168
},
183169
],
@@ -256,29 +242,15 @@ export default class MenuBuilder {
256242
label: 'Help',
257243
submenu: [
258244
{
259-
label: 'Learn More',
260-
click() {
261-
shell.openExternal('https://electronjs.org');
262-
},
263-
},
264-
{
265-
label: 'Documentation',
266-
click() {
267-
shell.openExternal(
268-
'https://github.com/electron/electron/tree/master/docs#readme'
269-
);
270-
},
271-
},
272-
{
273-
label: 'Community Discussions',
245+
label: 'Home Page',
274246
click() {
275-
shell.openExternal('https://www.electronjs.org/community');
247+
shell.openExternal('https://plainbelt.github.io');
276248
},
277249
},
278250
{
279-
label: 'Search Issues',
251+
label: 'GitHub',
280252
click() {
281-
shell.openExternal('https://github.com/electron/electron/issues');
253+
shell.openExternal('https://github.com/plainbelt/plainbelt');
282254
},
283255
},
284256
],

src/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "plainbelt",
33
"productName": "plainbelt",
4-
"version": "0.0.0",
4+
"version": "0.0.1",
55
"description": "A toolbelt for all your plain text",
66
"main": "./main.prod.js",
77
"author": {

yarn.lock

+27
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,13 @@
17851785
dependencies:
17861786
"@types/react" "*"
17871787

1788+
"@types/react-helmet@^6.1.2":
1789+
version "6.1.2"
1790+
resolved "https://registry.yarnpkg.com/@types/react-helmet/-/react-helmet-6.1.2.tgz#e9d7d16b29e4ec5716711c52c35c3cec45819eac"
1791+
integrity sha512-dcfAZNlWb5JYFbO9CGfrPWLJAyFcT6UeR3u35eBbv8liY2Rg4K7fM1G5+HnwVgot+C+kVwXAZ8pLEn2jsMfTDg==
1792+
dependencies:
1793+
"@types/react" "*"
1794+
17881795
"@types/react-router-dom@^5.1.6":
17891796
version "5.1.6"
17901797
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.1.6.tgz#07b14e7ab1893a837c8565634960dc398564b1fb"
@@ -10014,6 +10021,21 @@ react-dom@^17.0.1:
1001410021
object-assign "^4.1.1"
1001510022
scheduler "^0.20.1"
1001610023

10024+
react-fast-compare@^3.1.1:
10025+
version "3.2.0"
10026+
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"
10027+
integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==
10028+
10029+
react-helmet@^6.1.0:
10030+
version "6.1.0"
10031+
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-6.1.0.tgz#a750d5165cb13cf213e44747502652e794468726"
10032+
integrity sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==
10033+
dependencies:
10034+
object-assign "^4.1.1"
10035+
prop-types "^15.7.2"
10036+
react-fast-compare "^3.1.1"
10037+
react-side-effect "^2.1.0"
10038+
1001710039
react-is@^16.12.0, react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.6:
1001810040
version "16.13.1"
1001910041
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
@@ -10066,6 +10088,11 @@ react-shallow-renderer@^16.13.1:
1006610088
object-assign "^4.1.1"
1006710089
react-is "^16.12.0 || ^17.0.0"
1006810090

10091+
react-side-effect@^2.1.0:
10092+
version "2.1.1"
10093+
resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-2.1.1.tgz#66c5701c3e7560ab4822a4ee2742dee215d72eb3"
10094+
integrity sha512-2FoTQzRNTncBVtnzxFOk2mCpcfxQpenBMbk5kSVBg5UcPqV9fRbgY2zhb7GTWWOlpFmAxhClBDlIq8Rsubz1yQ==
10095+
1006910096
react-test-renderer@^16.0.0-0:
1007010097
version "16.14.0"
1007110098
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.14.0.tgz#e98360087348e260c56d4fe2315e970480c228ae"

0 commit comments

Comments
 (0)