fix image, add g-analytics, fix component binding
This commit is contained in:
parent
b8396ae2c7
commit
4c32b5f4f6
4 changed files with 46 additions and 27 deletions
|
@ -221,7 +221,7 @@ export const OFFICERS = [
|
|||
{
|
||||
name: "Raymond Wang",
|
||||
position: "Webmaster",
|
||||
photo: "img/officers/raymond.png",
|
||||
photo: "img/officers/raymond.jpg",
|
||||
email: "raymond@ucsd.edu",
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import * as React from "react";
|
||||
import { Component } from "react";
|
||||
|
||||
interface TopBarProps {
|
||||
links: {
|
||||
|
@ -12,7 +11,7 @@ interface TopBarState {
|
|||
menuVisible: boolean;
|
||||
}
|
||||
|
||||
export default class TopBar extends Component<TopBarProps, TopBarState> {
|
||||
export default class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
private static HAMBURGER_POINT = 1290;
|
||||
constructor(props: TopBarProps) {
|
||||
super(props);
|
||||
|
@ -20,7 +19,7 @@ export default class TopBar extends Component<TopBarProps, TopBarState> {
|
|||
showBurger: this.shouldShowBurger(),
|
||||
menuVisible: false,
|
||||
};
|
||||
this.toggleMenu.bind(this);
|
||||
this.toggleMenu = this.toggleMenu.bind(this);
|
||||
window.addEventListener("resize", this.checkResize.bind(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,15 @@ interface Website {
|
|||
|
||||
const APP = express();
|
||||
const TEMPLATE = fs
|
||||
.readFileSync(path.join(__dirname, "public/template.html"))
|
||||
.readFileSync(path.join(__dirname, "template.html"))
|
||||
.toString();
|
||||
|
||||
const GOOGLE_ANALYTICS_ID = process.env.GOOGLE_ANALYTICS_ID;
|
||||
|
||||
if (!GOOGLE_ANALYTICS_ID && process.env.NODE_ENV == "production") {
|
||||
throw new Error("GOOGLE_ANALYTICS_ID environment variable not defined");
|
||||
}
|
||||
|
||||
const WEBSITES = [
|
||||
{
|
||||
sitename: "index",
|
||||
|
@ -49,13 +56,13 @@ const WEBSITES = [
|
|||
jsfile: "js/committees.js",
|
||||
cssfile: "css/styles.css",
|
||||
themecolor: "",
|
||||
}
|
||||
},
|
||||
] as Website[];
|
||||
|
||||
const PORT = 9000;
|
||||
const PORT = process.env.PORT ?? 9000;
|
||||
|
||||
// Make the public directory traversible to people online
|
||||
APP.use(express.static(path.join(__dirname, "public")));
|
||||
APP.use(express.static(path.join(__dirname, "../public")));
|
||||
// Put the cookies as a variable in the request
|
||||
APP.use((req: Request, res: Response, next: NextFunction) => {
|
||||
req.cookies = req.headers.cookie;
|
||||
|
@ -99,6 +106,10 @@ function generatePage(name: string): string {
|
|||
for (key of Object.keys(site)) {
|
||||
html = html.replace(new RegExp("\\$" + key.toUpperCase()), site[key]);
|
||||
}
|
||||
html = html.replace(
|
||||
new RegExp("$GOOGLE_ANALYTICS_ID", "gm"),
|
||||
GOOGLE_ANALYTICS_ID
|
||||
);
|
||||
return html;
|
||||
}
|
||||
|
||||
|
@ -107,7 +118,7 @@ function generateFilePages() {
|
|||
for (site of WEBSITES) {
|
||||
const html = generatePage(site.sitename);
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, "public/", `${site.sitename}.html`),
|
||||
path.join(__dirname, "../public/", `${site.sitename}.html`),
|
||||
html
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,19 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>$TITLE</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/fonts.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="$CSSFILE" media="screen">
|
||||
<link rel="icon" href="img/favicon.ico" type="image/x-icon">
|
||||
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1">
|
||||
<meta name="description" content="$DESCRIPTION">
|
||||
<meta name="theme-color" content="$THEMECOLOR">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="text/javascript" src="$JSFILE"></script>
|
||||
</body>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>$TITLE</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/fonts.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="$CSSFILE" media="screen">
|
||||
<link rel="icon" href="img/favicon.ico" type="image/x-icon">
|
||||
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1">
|
||||
<meta name="description" content="$DESCRIPTION">
|
||||
<meta name="theme-color" content="$THEMECOLOR">
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=$GOOGLE_ANALYTICS_ID"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() { dataLayer.push(arguments); }
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', '$GOOGLE_ANALYTICS_ID');
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="text/javascript" src="$JSFILE"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue