Skip to content

Commit 2d2a5aa

Browse files
docs(website): add crawler and fix footer styling
1 parent 6ee7a74 commit 2d2a5aa

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

packages/overmind-website/backend/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path')
22
const express = require('express')
3+
const puppeteer = require('puppeteer')
34
const app = express()
45
const fs = require('fs')
56
const api = require('./api')
@@ -102,6 +103,26 @@ const apis = getApis()
102103

103104
const searchData = getSearchData()
104105

106+
const googleCrawlMiddleware = async function ssr(req, res, next) {
107+
if (
108+
req
109+
.get('user-agent')
110+
.toLowerCase()
111+
.indexOf('googlebot') >= 0
112+
) {
113+
const browser = await puppeteer.launch({ headless: true })
114+
const page = await browser.newPage()
115+
await page.goto(req.hostname + req.path, { waitUntil: 'networkidle0' })
116+
const html = await page.content()
117+
await browser.close()
118+
119+
res.send(html)
120+
} else {
121+
next()
122+
}
123+
}
124+
125+
app.use(googleCrawlMiddleware)
105126
app.use(express.static(path.join(__dirname, '..', 'dist')))
106127
app.use('/images', express.static(path.join(__dirname, '..', 'images')))
107128
app.get('/workshop/posts', api.posts)

packages/overmind-website/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"scripts": {
1010
"start": "node backend/index",
1111
"dev": "concurrently \"node backend/index.js\" \"webpack-dev-server --port 4000 --mode development --hot --inline\"",
12-
"build": "webpack --mode=production",
13-
"now-build": "npm run build",
12+
"build": "webpack --mode=production",
13+
"now-build": "npm run build",
1414
"typecheck": "tsc --noEmit",
1515
"prepare": "npm run build",
1616
"posttest": "npm run typecheck"
@@ -40,9 +40,10 @@
4040
"install": "^0.12.1",
4141
"marksy": "^6.1.0",
4242
"npm": "^6.3.0",
43-
"overmind-react": "next",
43+
"overmind-react": "next",
4444
"page": "^1.8.6",
45-
"prismjs": "^1.15.0"
45+
"prismjs": "^1.15.0",
46+
"puppeteer": "^1.11.0"
4647
},
4748
"devDependencies": {
4849
"@babel/plugin-transform-react-jsx": "^7.1.6",

packages/overmind-website/src/components/App/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ const App: SFC = () => {
5050
return (
5151
<div ref={mainRef} className={styles.wrapper}>
5252
{isMobile ? <MobileTopBar /> : <TopBar />}
53-
<Page />
53+
<div className={styles.pageWrapper}>
54+
<Page />
55+
</div>
5456
<Footer />
5557
</div>
5658
)

packages/overmind-website/src/components/App/styles.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { css } from 'emotion'
22

3+
export const pageWrapper = css`
4+
min-height: calc(100vh - 198px);
5+
`
6+
37
export const wrapper = css`
48
font-family: Nunito, 'helvetica neue';
59
background-color: inherit;

packages/overmind-website/src/components/Footer/styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const wrapper = css`
66
height: 100px;
77
justify-content: center;
88
align-items: center;
9+
margin-top: var(--padding-6);
910
> * {
1011
margin: 0 var(--padding-4);
1112
}

packages/overmind-website/src/components/FrontPage/styles.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const wrapper = css`
55
padding-top: 100px;
66
display: flex;
77
box-sizing: border-box;
8-
height: 100vh;
98
justify-content: center;
109
1110
@media (max-width: 700px) {

0 commit comments

Comments
 (0)