homepage-frontend/src/router.js

34 lines
785 B
JavaScript
Raw Normal View History

2017-07-23 15:24:59 +00:00
//@flow
2017-07-28 21:03:26 +00:00
import express, { Router } from "express"
import Inferno from "inferno"
import InfernoServer from 'inferno-server'
import { ServerStyleSheet } from 'styled-components'
import styled from "styled-components"
import App from "./app"
2017-07-23 15:24:59 +00:00
import path from "path"
2017-07-28 21:03:26 +00:00
import ejs from "ejs"
import indexFile from "raw-loader!./index.ejs"
2017-07-23 15:24:59 +00:00
const router = new Router
2017-07-28 21:03:26 +00:00
const sheet = new ServerStyleSheet()
const template = ejs.compile(indexFile)
const content = InfernoServer.renderToStaticMarkup(sheet.collectStyles(<App />))
const title = "Arwed Mett"
const style = sheet.getStyleTags()
const indexPage = template({
content,
title,
style
2017-07-23 15:24:59 +00:00
})
2017-07-28 21:03:26 +00:00
router.get("/", (req, res, next) => {
res.send(indexPage)
2017-07-23 15:24:59 +00:00
})
2017-07-28 21:03:26 +00:00
router.use(express.static(path.join(__dirname, "static")))
2017-07-23 15:24:59 +00:00
export default router