From: Orvar Segerström Date: Mon, 26 Oct 2020 14:28:17 +0000 (+0100) Subject: Use helmet for theme inclusion instead X-Git-Url: http://these/git/%22https:/nerdica.net/%7B%24%7B%60data:application/static/%7BinboxRss%7D?a=commitdiff_plain;h=b8a47be3dfb139e2346bb9da8e3392acefa4ff25;p=lemmy-ui.git Use helmet for theme inclusion instead --- diff --git a/src/server/index.tsx b/src/server/index.tsx index 34bd453..c8d6044 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 a435070..67d9459 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 0000000..558f9a8 --- /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 ?? ( + <> + + + + )} + + ); +};