Skip to content

Commit

Permalink
🔧 Move config to single file
Browse files Browse the repository at this point in the history
  • Loading branch information
WincerChan committed Jan 20, 2019
1 parent 01063fb commit d8f5726
Show file tree
Hide file tree
Showing 13 changed files with 2,713 additions and 2,836 deletions.
4 changes: 1 addition & 3 deletions public/index.html

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { Component } from "react";
import { Link } from "gatsby";
const templates = require('./config.json')
import 'bulma/css/bulma.css'
import './layout.css'
import getConfig from './config'

const Title = "Meme",
navbarItems = [
Expand All @@ -25,6 +27,7 @@ class Navbar extends Component {
this.state = {
navBarIsActive: false
}
this.configs = getConfig()
}

toggleNavbar = () => {
Expand Down Expand Up @@ -60,7 +63,7 @@ class Navbar extends Component {
{menuName}
</a>
<div className="navbar-dropdown is-boxed">
{templates.map((item, i) =>
{this.configs.map((item, i) =>
<Link key={i} className="navbar-item" to={item.url}>{item.name}</Link>
)}
</div>
Expand Down
26 changes: 0 additions & 26 deletions src/components/config.json

This file was deleted.

13 changes: 13 additions & 0 deletions src/components/config.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const getConfig = () => {
return [
require("../pages/woshuode").config,
require("../pages/wangjingze").config,
require("../pages/weisuoyuwei").config,
require("../pages/lianliankan").config,
require("../pages/shuifandui").config,
require("../pages/dagong").config
]
}
// const configs = Object.values(pages).filter(value => value !== undefined && value.hasOwnProperty("url"));

export default getConfig;
1 change: 0 additions & 1 deletion src/components/template.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component } from 'react';
import 'bulma/css/bulma.css'
import SEO from './seo';
import Navbar from './Navbar'
import GIF from 'gif.js';
Expand Down
5 changes: 4 additions & 1 deletion src/pages/dagong.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import React from 'react'
import { Template } from '../components/template';
const config = {
"name": "打工是不可能打工的",
"url": "/dagong/",
"gif": "/template/dagong.gif",
"config": [
{
Expand Down Expand Up @@ -37,6 +37,9 @@ const config = {
}
]
}
export { config };

export default () => (
<Template element={config} />
)

5 changes: 4 additions & 1 deletion src/pages/lianliankan.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { Template } from '../components/template';
const config = {
"name": "星际还是魔兽",
"url": "/lianliankan/",
"gif": "/template/lianliankan.gif",
"config": [
{
Expand All @@ -27,6 +28,8 @@ const config = {
]
}


export { config };
export default () => (
<Template element={config} />
)
)
5 changes: 4 additions & 1 deletion src/pages/shuifandui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import { Template } from '../components/template';
const config = {
"name": "谁赞成,谁反对",
"url": "/shuifandui/",
"gif": "/template/shuifandui.gif",
"config": [
{
Expand All @@ -27,6 +28,8 @@ const config = {
}
]
}

export { config };
export default () => (
<Template element={config} />
)
)
3 changes: 3 additions & 0 deletions src/pages/wangjingze.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import { Template } from '../components/template';
const config = {
"name": "王境泽",
"url": "/wangjingze/",
"gif": "/template/wangjingze.gif",
"config": [
{
Expand All @@ -27,6 +28,8 @@ const config = {
}
]
}
export { config };

export default () => (
<Template element={config} />
)
5 changes: 4 additions & 1 deletion src/pages/weisuoyuwei.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import { Template } from '../components/template';
const config = {
"name": "为所欲为",
"url": "/weisuoyuwei/",
"gif": "/template/weisuoyuwei.gif",
"config": [
{
Expand Down Expand Up @@ -52,6 +53,8 @@ const config = {
}
]
}

export { config };
export default () => (
<Template element={config} />
)
)
5 changes: 4 additions & 1 deletion src/pages/woshuode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import { Template } from '../components/template';
const config = {
"name": "我说的",
"url": "/woshuode/",
"gif": "/template/woshuode.gif",
"config": [
{
Expand All @@ -22,6 +23,8 @@ const config = {
}
]
}

export { config };
export default () => (
<Template element={config} />
)
)
51 changes: 0 additions & 51 deletions static/index.html

This file was deleted.

Loading

0 comments on commit d8f5726

Please sign in to comment.