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",
|
name: "Raymond Wang",
|
||||||
position: "Webmaster",
|
position: "Webmaster",
|
||||||
photo: "img/officers/raymond.png",
|
photo: "img/officers/raymond.jpg",
|
||||||
email: "raymond@ucsd.edu",
|
email: "raymond@ucsd.edu",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { Component } from "react";
|
|
||||||
|
|
||||||
interface TopBarProps {
|
interface TopBarProps {
|
||||||
links: {
|
links: {
|
||||||
|
@ -12,7 +11,7 @@ interface TopBarState {
|
||||||
menuVisible: boolean;
|
menuVisible: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class TopBar extends Component<TopBarProps, TopBarState> {
|
export default class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||||
private static HAMBURGER_POINT = 1290;
|
private static HAMBURGER_POINT = 1290;
|
||||||
constructor(props: TopBarProps) {
|
constructor(props: TopBarProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -20,7 +19,7 @@ export default class TopBar extends Component<TopBarProps, TopBarState> {
|
||||||
showBurger: this.shouldShowBurger(),
|
showBurger: this.shouldShowBurger(),
|
||||||
menuVisible: false,
|
menuVisible: false,
|
||||||
};
|
};
|
||||||
this.toggleMenu.bind(this);
|
this.toggleMenu = this.toggleMenu.bind(this);
|
||||||
window.addEventListener("resize", this.checkResize.bind(this));
|
window.addEventListener("resize", this.checkResize.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,15 @@ interface Website {
|
||||||
|
|
||||||
const APP = express();
|
const APP = express();
|
||||||
const TEMPLATE = fs
|
const TEMPLATE = fs
|
||||||
.readFileSync(path.join(__dirname, "public/template.html"))
|
.readFileSync(path.join(__dirname, "template.html"))
|
||||||
.toString();
|
.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 = [
|
const WEBSITES = [
|
||||||
{
|
{
|
||||||
sitename: "index",
|
sitename: "index",
|
||||||
|
@ -49,13 +56,13 @@ const WEBSITES = [
|
||||||
jsfile: "js/committees.js",
|
jsfile: "js/committees.js",
|
||||||
cssfile: "css/styles.css",
|
cssfile: "css/styles.css",
|
||||||
themecolor: "",
|
themecolor: "",
|
||||||
}
|
},
|
||||||
] as Website[];
|
] as Website[];
|
||||||
|
|
||||||
const PORT = 9000;
|
const PORT = process.env.PORT ?? 9000;
|
||||||
|
|
||||||
// Make the public directory traversible to people online
|
// 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
|
// Put the cookies as a variable in the request
|
||||||
APP.use((req: Request, res: Response, next: NextFunction) => {
|
APP.use((req: Request, res: Response, next: NextFunction) => {
|
||||||
req.cookies = req.headers.cookie;
|
req.cookies = req.headers.cookie;
|
||||||
|
@ -99,6 +106,10 @@ function generatePage(name: string): string {
|
||||||
for (key of Object.keys(site)) {
|
for (key of Object.keys(site)) {
|
||||||
html = html.replace(new RegExp("\\$" + key.toUpperCase()), site[key]);
|
html = html.replace(new RegExp("\\$" + key.toUpperCase()), site[key]);
|
||||||
}
|
}
|
||||||
|
html = html.replace(
|
||||||
|
new RegExp("$GOOGLE_ANALYTICS_ID", "gm"),
|
||||||
|
GOOGLE_ANALYTICS_ID
|
||||||
|
);
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +118,7 @@ function generateFilePages() {
|
||||||
for (site of WEBSITES) {
|
for (site of WEBSITES) {
|
||||||
const html = generatePage(site.sitename);
|
const html = generatePage(site.sitename);
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(__dirname, "public/", `${site.sitename}.html`),
|
path.join(__dirname, "../public/", `${site.sitename}.html`),
|
||||||
html
|
html
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,15 @@
|
||||||
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1">
|
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1">
|
||||||
<meta name="description" content="$DESCRIPTION">
|
<meta name="description" content="$DESCRIPTION">
|
||||||
<meta name="theme-color" content="$THEMECOLOR">
|
<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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
Loading…
Reference in a new issue