diff options
| author | Haishan <[email protected]> | 2020-10-31 17:57:39 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2020-10-31 20:10:23 +0800 |
| commit | e62c9165481ef12ee2310dee1c32f890b3fe4b78 (patch) | |
| tree | 3c8fa421f3bf46065fc65cd0ee687c8d79b3cbf7 /src/components/shared | |
| parent | cbb6b9c9bbfee296ce0ea1f1ba18a66a41ac02e1 (diff) | |
feat: display current backend host in title
for https://github.com/haishanh/yacd/issues/531
Diffstat (limited to 'src/components/shared')
| -rw-r--r-- | src/components/shared/Head.tsx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/components/shared/Head.tsx b/src/components/shared/Head.tsx new file mode 100644 index 0000000..5997a3a --- /dev/null +++ b/src/components/shared/Head.tsx @@ -0,0 +1,24 @@ +import * as React from 'react'; +import { Helmet } from 'react-helmet'; +import { connect } from 'src/components/StateProvider'; +import { getClashAPIConfig } from 'src/store/app'; + +const mapState = (s) => ({ + apiConfig: getClashAPIConfig(s), +}); + +function HeadImpl({ apiConfig }: { apiConfig: { baseURL: string } }) { + let title = 'yacd'; + try { + title = new URL(apiConfig.baseURL).host; + } catch (e) { + // ignore + } + return ( + <Helmet> + <title>{title}</title> + </Helmet> + ); +} + +export const Head = connect(mapState)(HeadImpl); |
