Skip to content

Commit

Permalink
Serve favicons along with our Gatsby static assets
Browse files Browse the repository at this point in the history
There's no good reason to call these files out specifically in app.js or
handle them with special packages like serve-favicon.
  • Loading branch information
tsibley committed Nov 19, 2021
1 parent 5171a53 commit 584757a
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 37 deletions.
29 changes: 0 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"query-string": "^4.2.3",
"react-icons": "^3.11.0",
"request": "^2.88.0",
"serve-favicon": "^2.5.0",
"session-file-store": "^1.3.1",
"yaml-front-matter": "^4.0.0"
},
Expand Down
5 changes: 1 addition & 4 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const sslRedirect = require('heroku-ssl-redirect');
const nakedRedirect = require('express-naked-redirect');
const express = require("express");
const favicon = require('serve-favicon');
const compression = require('compression');
const utils = require("./utils");
const cors = require('cors');
Expand All @@ -13,7 +12,7 @@ const production = process.env.NODE_ENV === "production";

const charon = require("./endpoints/charon");
const users = require("./endpoints/users");
const {assetPath, auspiceAssets, gatsbyAssets, sendAuspiceEntrypoint, sendGatsbyEntrypoint, sendGatsbyPage, sendGatsby404} = require("./endpoints/static");
const {auspiceAssets, gatsbyAssets, sendAuspiceEntrypoint, sendGatsbyEntrypoint, sendGatsbyPage, sendGatsby404} = require("./endpoints/static");
const {setSource, setGroupSource, setDataset, setNarrative, canonicalizeDataset, ifDatasetExists, ifNarrativeExists} = require("./endpoints/sources");
const authn = require("./authn");
const redirects = require("./redirects");
Expand All @@ -35,8 +34,6 @@ if (production) app.enable("trust proxy");
app.use(sslRedirect()); // redirect HTTP to HTTPS
app.use(compression()); // send files (e.g. res.json()) using compression (if possible)
app.use(nakedRedirect({reverse: true})); // redirect www.nextstrain.org to nextstrain.org
app.use(favicon(assetPath("favicon.ico")));
app.use('/favicon.png', express.static(assetPath("favicon.png")));


/* Setup a request-scoped context object for passing arbitrary request-local
Expand Down
3 changes: 1 addition & 2 deletions src/endpoints/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require("path");
const utils = require("../utils");


/* Path helpers for static assets, to make routes more readable.
/* Path helpers for our handlers below.
*/
const assetPath = (...subpath) =>
path.join(__dirname, "..", "..", ...subpath);
Expand Down Expand Up @@ -157,7 +157,6 @@ const sendGatsby404 = async (req, res) => {


module.exports = {
assetPath,
auspiceAssets,
gatsbyAssets,

Expand Down
2 changes: 1 addition & 1 deletion static-site/src/html.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint import/extensions:"off" */
/* eslint global-require:"off" */
import React from "react";
import favicon from "../../favicon.png";
import favicon from "../static/favicon.png";

// eslint-disable-next-line react/prefer-stateless-function
export default class HTML extends React.Component {
Expand Down
File renamed without changes.
File renamed without changes

0 comments on commit 584757a

Please sign in to comment.