Skip to content

Commit

Permalink
Merge pull request #88 from cofacts/landing-page
Browse files Browse the repository at this point in the history
Temp landing page
  • Loading branch information
bil4444 committed Mar 25, 2018
2 parents 711bf47 + 021d376 commit 5c8390a
Show file tree
Hide file tree
Showing 27 changed files with 265 additions and 14 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,27 @@ If you found that `BUILD_TARGET` does not work (i.e. the server still sends to p

See: https://github.com/zeit/styled-jsx#syntax-highlighting

## Landing Page (Makeshift)

We build a temporary landing page in the repo [grants-landing-template](github.com/cofacts/grants-landing-template).

When the landing page repo is in the same directory of this repo, run the command below to update the landing page in this repo:

``` bash
grants-landing-template $ npm start
# After the landing page is compiled, ctrl-c

grants-landing-template $ cd ../rumors-site

rumors-site $ npm run landing
```


## Deploy

Build docker image

```
``` bash
# Production build
$ npm run build

Expand All @@ -45,12 +61,12 @@ $ npm run build:staging

Run the docker image on local machine, then visit `http://localhost:3000`.

```
``` bash
$ docker run --rm -p 3000:3000 -e "PORT=3000" mrorz/rumors-site
```

Push to dockerhub
```
``` bash
# Production
$ docker push mrorz/rumors-site

Expand Down
10 changes: 4 additions & 6 deletions components/App/AppHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import { showDialog, logout } from 'ducks/auth';
function AppHeader({ user, onLoginClick, onLogoutClick }) {
return (
<header className="root">
<Link route="home">
<a className="logo hidden-xs">
<h1>真的假的</h1>
</a>
</Link>
<a className="logo hidden-xs" href="/">
<h1>真的假的</h1>
</a>
<nav className="nav">
<Link route="home">
<Link route="articles">
<a className="nav-item">文章</a>
</Link>
<Link route="replies">
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"build:next": "next build",
"build:server": "babel server.js -o server.dist.js",
"init:autotrack": "autotrack -o static/$npm_package_config_autotrackFileName -p eventTracker,outboundLinkTracker,urlChangeTracker",
"start": "NODE_ENV=production node server.dist.js"
"start": "NODE_ENV=production node server.dist.js",
"landing": "cp -R ../grants-landing-template/static/* static/"
},
"config": {
"autotrackFileName": "autotrack.custom.js"
Expand All @@ -31,6 +32,7 @@
"immutable": "^3.8.2",
"isomorphic-fetch": "^2.2.1",
"koa": "^2.4.1",
"koa-send": "^4.1.3",
"next": "^4.1.4",
"next-routes": "^1.1.0",
"normalize.css": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion pages/index.js → pages/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Pagination from 'components/Pagination';
import ArticleItem from 'components/ArticleItem';
import { load, loadAuthFields } from 'ducks/articleList';

import { mainStyle, hintStyle } from './index.styles';
import { mainStyle, hintStyle } from './articles.styles';

class Index extends ListPage {
state = {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pages/replies.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ListPage from 'components/ListPage';
import Pagination from 'components/Pagination';
import ReplyItem from 'components/ReplyItem';

import { mainStyle } from './index.styles';
import { mainStyle } from './articles.styles';

class ReplyList extends ListPage {
handleMyReplyOnlyCheck = e => {
Expand Down
3 changes: 1 addition & 2 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const routes = (module.exports = require('next-routes')());

routes
// routes.add(name, pattern = /name, page = name)
.add('home', '/', 'index')
.add('articles', '/', 'index')
.add('articles', '/articles', 'articles')
.add('replies', '/replies', 'replies')
// routes.add({name: 'name', pattern: '/name', page: 'name'})
.add({
Expand Down
10 changes: 10 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const Koa = require('koa');
const next = require('next');
const Rollbar = require('rollbar');
const send = require('koa-send');

// Server related config & credentials
//
Expand Down Expand Up @@ -38,6 +39,15 @@ app.prepare().then(() => {
}
});

//
server.use(async (ctx, next) => {
if ('/' === ctx.path) {
await send(ctx, './static/index.html');
} else {
await next();
}
});

// Server-side routing
//

Expand Down
Binary file added static/img/cofacts-db-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions static/img/g0v-bg-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5c8390a

Please sign in to comment.