Skip to content

Commit f4a1bb1

Browse files
committed
removed model/head.js
1 parent 080d7d9 commit f4a1bb1

File tree

12 files changed

+64
-53
lines changed

12 files changed

+64
-53
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react2html",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "react2html - component based web site development starter kit",
55
"private": false,
66
"homepage": "https://github.com/modesty/react2html",

src/scripts/components/Head.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import React from 'react';
22

3-
import processRelPath from '../model/head';
4-
5-
const Head = ({ title, description, styles, scripts, rel }) => {
6-
const { touchHref, webMan, styleLinks, scriptLinks } = processRelPath(rel, styles, scripts);
3+
const Head = ({ title, description, links, styles, scripts }) => {
74
return (
85
<head>
96
<meta charSet="utf-8" />
107
<title>{title}</title>
118
<meta name="description" content={description} />
129
<meta name="viewport" content="width=device-width, initial-scale=1" />
1310

14-
<link rel="manifest" href={webMan} />
15-
<link rel="apple-touch-icon" href={touchHref} />
11+
{Object.entries(links).map((entry, i) => <link key={i} rel={entry[0]} href={entry[1]} />)}
12+
{styles.map( (s, i) => <link rel="stylesheet" href={s} key={i} /> )}
13+
{scripts.map((s, i) => <script src={s} key={i} />)}
1614

17-
{styleLinks.map( (s, i) => <link rel="stylesheet" href={s} key={i} /> )}
18-
{scriptLinks.map((s, i) => <script src={s} key={i} />)}
1915
<meta name="theme-color" content="#fafafa" />
2016
</head>
2117
);

src/scripts/components/Header.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import Menu from './Menu';
44

55
import processRelPath from '../model/header';
66

7-
const Header = ({ title, rel }) => {
8-
let dataModel = processRelPath(rel);
9-
let {homeLink, bannerLink} = dataModel;
7+
const Header = ({ title, rel = "" }) => {
8+
const { homeLink, bannerLink, socials } = processRelPath(rel);
109

1110
return (
1211
<header className='header'>
@@ -28,7 +27,7 @@ const Header = ({ title, rel }) => {
2827
<div className="col-md-3 hidden-sm hidden-xs">
2928
<div className="soc-area">
3029
<div className="icons-social">
31-
{dataModel.socials.map( s => <a href={s.href} className={s.id} key={s.id}></a>)}
30+
{socials.map( s => <a href={s.href} className={s.id} key={s.id}></a>)}
3231
</div>
3332
</div>
3433
</div>

src/scripts/components/Main.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
"use strict";
2-
31
import React from 'react';
42

5-
let Main = (props) =>
3+
const Main = (props) =>
64
<main className=''>
75
{props.children}
86
</main>;

src/scripts/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import Header from './components/Header';
55
import Main from './components/Main';
66
import Footer from './components/Footer';
77

8-
const Root = ({title,description,scripts,styles,rel, gaKey}) => {
8+
const Root = ({title,description,links,scripts,styles,rel, gaKey}) => {
99
return (
1010
<html className="no-js" lang="en">
11-
<Head title={title} description={description} scripts={scripts} styles={styles} rel={rel} />
11+
<Head title={title} description={description} links={links} scripts={scripts} styles={styles} rel={rel} />
1212
<body data-track={gaKey} className='container'>
1313
<Header title={title} />
1414
<Main>

src/scripts/model/head.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/scripts/model/header.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'path';
2+
13
const HeaderModel = {
24
homeLink: {name: "Home", href: "./", img: "img/logo.png"},
35
bannerLink: {name: "Banner Ad", href: "", img: "http://placehold.it/420x60"},
@@ -11,12 +13,7 @@ const HeaderModel = {
1113
]
1214
};
1315

14-
export default function processRelPath(rel) {
15-
let relPath = rel ? rel : "";
16-
17-
let homeLink = HeaderModel.homeLink, bannerLink = HeaderModel.bannerLink;
18-
19-
homeLink = {...homeLink, href: relPath + homeLink.href, img: relPath + homeLink.img};
20-
21-
return {...HeaderModel, homeLink: homeLink};
16+
export default function processRelPath(rel = "") {
17+
const { homeLink:preHomeLink } = HeaderModel;
18+
return {...HeaderModel, homeLink: {...preHomeLink, href: path.join(rel, preHomeLink.href), img: path.join(rel, preHomeLink.img)}};
2219
}

src/scripts/pages/about.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import Header from '../components/Header';
55
import Main from '../components/Main';
66
import Footer from '../components/Footer';
77

8-
const About = ({title,description,scripts,styles,rel, gaKey}) => {
8+
const About = ({title,description,links, scripts,styles,rel, gaKey}) => {
99
return (
1010
<html className="no-js" lang="en">
11-
<Head title={title} description={description} scripts={scripts} styles={styles} rel={rel} />
11+
<Head title={title} description={description} links={links} scripts={scripts} styles={styles} rel={rel} />
1212
<body data-track={gaKey} className='container'>
13-
<Header title={title} />
13+
<Header title={title} rel={rel} />
1414
<Main>
1515
<h1>About React2Html</h1>
1616
<p>More details can be found at <a href="https://github.com/modesty/react2html"> GitHub </a></p>

src/scripts/pages/contact.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import Header from '../components/Header';
55
import Main from '../components/Main';
66
import Footer from '../components/Footer';
77

8-
const Contact = ({title,description,scripts,styles,rel, gaKey}) => {
8+
const Contact = ({title,description,links,scripts,styles,rel,gaKey}) => {
99
return (
1010
<html className="no-js" lang="en">
11-
<Head title={title} description={description} scripts={scripts} styles={styles} rel={rel} />
11+
<Head title={title} description={description} links={links} scripts={scripts} styles={styles} rel={rel} />
1212
<body data-track={gaKey} className='container'>
13-
<Header title={title} />
13+
<Header title={title} rel={rel} />
1414
<Main>
1515
<h1>Contact Me</h1>
1616
<p>email the author: <a href="mailto:[email protected]?subject=About%20CoeProject%20Article">[email protected]</a></p>

src/scripts/props/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
import path from 'path';
2+
import glob from 'glob';
3+
14
const pkg = require('../../../package.json');
25
import Conf from '../../../tool/base.config';
3-
import glob from 'glob';
46

57
export default {
68
title: `Welcome to ${pkg.name} v${pkg.version}`,
79
description: pkg.description,
8-
scripts: glob.sync('**/*.js', { cwd: Conf.target.js_path }),
9-
styles: glob.sync('**/*.css', { cwd: Conf.target.css_path }),
10-
rel: './',
10+
links: {
11+
"site.webmanifest": "site.webmanifest",
12+
"apple-touch-icon": "apple-touch-icon.png"
13+
},
14+
scripts: glob.sync('**/*.js', { cwd: Conf.target.js_path }).map(s => path.join("js", s)),
15+
styles: glob.sync('**/*.css', { cwd: Conf.target.css_path }).map( s => path.join("css", s)),
16+
rel: '',
1117
gaKey: Conf.TRACK_ID
1218
}

0 commit comments

Comments
 (0)