Fix symbols issue. Fixes #319

This commit is contained in:
Dessalines 2021-07-16 12:51:54 -04:00
parent 40a14b5ebe
commit 1a4db014d7
4 changed files with 181 additions and 187 deletions

View file

@ -15,6 +15,7 @@ import IsomorphicCookie from "isomorphic-cookie";
import { GetSite, GetSiteResponse, LemmyHttp } from "lemmy-js-client"; import { GetSite, GetSiteResponse, LemmyHttp } from "lemmy-js-client";
import process from "process"; import process from "process";
import { Helmet } from "inferno-helmet"; import { Helmet } from "inferno-helmet";
import { SYMBOLS } from "../shared/components/symbols";
import { initializeSite } from "../shared/initialize"; import { initializeSite } from "../shared/initialize";
import { httpBaseInternal } from "../shared/env"; import { httpBaseInternal } from "../shared/env";
import { IncomingHttpHeaders } from "http"; import { IncomingHttpHeaders } from "http";
@ -109,6 +110,7 @@ server.get("/*", async (req, res) => {
); );
const root = renderToString(wrapper); const root = renderToString(wrapper);
const symbols = renderToString(SYMBOLS);
const cspStr = process.env.LEMMY_EXTERNAL_HOST ? renderToString(cspHtml) : ""; const cspStr = process.env.LEMMY_EXTERNAL_HOST ? renderToString(cspHtml) : "";
const helmet = Helmet.renderStatic(); const helmet = Helmet.renderStatic();
@ -140,6 +142,10 @@ server.get("/*", async (req, res) => {
<!-- Current theme and more --> <!-- Current theme and more -->
${helmet.link.toString()} ${helmet.link.toString()}
<!-- Icons -->
${symbols}
</head> </head>
<body ${helmet.bodyAttributes.toString()}> <body ${helmet.bodyAttributes.toString()}>
@ -160,9 +166,9 @@ server.listen(Number(port), hostname, () => {
console.log(`http://${hostname}:${port}`); console.log(`http://${hostname}:${port}`);
}); });
function setForwardedHeaders( function setForwardedHeaders(headers: IncomingHttpHeaders): {
headers: IncomingHttpHeaders [key: string]: string;
): { [key: string]: string } { } {
let out = { let out = {
host: headers.host, host: headers.host,
}; };

View file

@ -8,7 +8,6 @@ import { Navbar } from "./navbar";
import { Footer } from "./footer"; import { Footer } from "./footer";
import { NoMatch } from "./no-match"; import { NoMatch } from "./no-match";
import { Theme } from "./theme"; import { Theme } from "./theme";
import { Symbols } from "./symbols";
import { GetSiteResponse } from "lemmy-js-client"; import { GetSiteResponse } from "lemmy-js-client";
import "./styles.scss"; import "./styles.scss";
import { favIconPngUrl, favIconUrl } from "../utils"; import { favIconPngUrl, favIconUrl } from "../utils";
@ -59,7 +58,6 @@ export class App extends Component<AppProps, any> {
))} ))}
<Route render={props => <NoMatch {...props} />} /> <Route render={props => <NoMatch {...props} />} />
</Switch> </Switch>
<Symbols />
</div> </div>
<Footer site={this.props.siteRes} /> <Footer site={this.props.siteRes} />
</div> </div>

View file

@ -13,10 +13,10 @@ export class Icon extends Component<IconProps, any> {
render() { render() {
return ( return (
<svg class={`icon ${this.props.classes}`}> <svg class={`icon ${this.props.classes}`}>
<use xlinkHref={`#icon-${this.props.icon}`}></use>
<div class="sr-only"> <div class="sr-only">
<title>{this.props.icon}</title> <title>{this.props.icon}</title>
</div> </div>
<use xlinkHref={`#icon-${this.props.icon}`}></use>
</svg> </svg>
); );
} }

View file

@ -1,12 +1,4 @@
import { Component } from "inferno"; export const SYMBOLS = (
export class Symbols extends Component<any, any> {
constructor(props: any, context: any) {
super(props, context);
}
render() {
return (
<svg <svg
aria-hidden="true" aria-hidden="true"
style={{ style={{
@ -176,6 +168,4 @@ export class Symbols extends Component<any, any> {
</symbol> </symbol>
</defs> </defs>
</svg> </svg>
); );
}
}