From b8a47be3dfb139e2346bb9da8e3392acefa4ff25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orvar=20Segerstr=C3=B6m?= Date: Mon, 26 Oct 2020 15:28:17 +0100 Subject: [PATCH] Use helmet for theme inclusion instead --- src/server/index.tsx | 22 +++----------------- src/shared/components/app.tsx | 3 ++- src/shared/components/theme.tsx | 36 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 src/shared/components/theme.tsx diff --git a/src/server/index.tsx b/src/server/index.tsx index 34bd4536..c8d60448 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -61,17 +61,6 @@ server.get('/*', async (req, res) => { }; initializeSite(site); - const user = site.my_user; - const userTheme = - user && - user.theme && - ` - - `; const wrapper = ( @@ -93,7 +82,6 @@ server.get('/*', async (req, res) => { ${helmet.title.toString()} ${helmet.meta.toString()} - ${helmet.link.toString()} @@ -109,13 +97,9 @@ server.get('/*', async (req, res) => { - ${ - userTheme ?? - ` - - - `.trim() - } + + + ${helmet.link.toString()} diff --git a/src/shared/components/app.tsx b/src/shared/components/app.tsx index a4350705..67d94591 100644 --- a/src/shared/components/app.tsx +++ b/src/shared/components/app.tsx @@ -6,9 +6,9 @@ import { i18n } from '../i18next'; import { routes } from '../../shared/routes'; import { Navbar } from '../../shared/components/navbar'; import { Footer } from '../../shared/components/footer'; +import { Theme } from './theme'; import { Symbols } from '../../shared/components/symbols'; import { GetSiteResponse } from 'lemmy-js-client'; -import { UserService } from '../../shared/services'; import './styles.scss'; export interface AppProps { @@ -24,6 +24,7 @@ export class App extends Component { <>
+ {this.props.site && this.props.site.site && this.props.site.site.icon && ( diff --git a/src/shared/components/theme.tsx b/src/shared/components/theme.tsx new file mode 100644 index 00000000..558f9a8b --- /dev/null +++ b/src/shared/components/theme.tsx @@ -0,0 +1,36 @@ +import { User } from 'lemmy-js-client'; +import { Helmet } from 'inferno-helmet'; + +export const Theme = (props: { user: User | undefined }) => { + const user = props.user; + const userTheme = user && user.theme && ( + + ); + + return ( + + {userTheme ?? ( + <> + + + + )} + + ); +};