Skip to content

Commit

Permalink
Bugfixing (#7)
Browse files Browse the repository at this point in the history
* trying to fix load problem

* fixed path problem and menu

* added batch to all posts and corrected name prop

* fixed bugs and added pagehead component
  • Loading branch information
tegner authored Jun 21, 2018
1 parent cbea061 commit b5bce11
Show file tree
Hide file tree
Showing 13 changed files with 1,715 additions and 966 deletions.
1 change: 1 addition & 0 deletions content/posts/light-afternoon-shower.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: "Light Afternoon Shower"
date: "2017-06-09"
brewed: "2017-06-09"
bottled: "N/A"
batch: "20170609"
ibu: "60"
srm: "1"
abv: "4%"
Expand Down
1 change: 1 addition & 0 deletions content/posts/mosekonen-brygger.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: "Mosekonen brygger"
date: "2018-05-04"
brewed: "2018-04-18"
bottled: "2018-05-04"
batch: "20180504"
ibu: "18"
srm: "9"
abv: "5.4%"
Expand Down
1 change: 1 addition & 0 deletions content/posts/mr-white-ipa.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: "Mr. White IPA"
date: "2017-03-21"
brewed: "2017-03-21"
bottled: "N/A"
batch: "20170321"
ibu: "45"
srm: "N/A"
abv: "5.5%"
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"main": "index.js",
"scripts": {
"start": "phenomic start",
"build": "npm run lint && phenomic build",
"lint": "prettier ./public/**/*.css --write && prettier ./src/*.js --single-quote --write"
"preview": "phenomic preview",
"build": "phenomic build",
"prebuild": "prettier ./public/**/*.css --write && prettier ./src/*.js --single-quote --write"
},
"author": "tegner",
"license": "ISC",
Expand All @@ -21,6 +22,12 @@
"react-router": "^3.2.1"
},
"phenomic": {
"content": {
"": {
"root": "content",
"globs": ["**/*"]
}
},
"presets": [
"@phenomic/preset-react-app"
]
Expand Down
1 change: 1 addition & 0 deletions public/css/biglink.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.biglink {
align-items: flex-end;
background: #888;
background-position: center;
color: #000;
display: flex;
font-size: 18px;
Expand Down
3 changes: 1 addition & 2 deletions src/BigLink.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import Head from 'react-helmet';
import { Router, Route, browserHistory, Link } from 'react-router';
import { Link } from 'react-router';

const BigLink = ({ props }) => (
<Link
Expand Down
22 changes: 8 additions & 14 deletions src/BlogPostComponent.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import React from 'react';
import Head from 'react-helmet';
import { Router, Route, browserHistory, Link } from 'react-router';
import {
withPhenomicApi,
query,
BodyRenderer,
textRenderer
} from '@phenomic/preset-react-app/lib/client';
import { Layout } from './Layout';
import { PageError } from './PageError';
import { Menu, MenuContainer } from './Menu';
import { PageHead } from './PageHead';

class BlogPost extends React.Component {
constructor(props) {
Expand All @@ -19,19 +16,16 @@ class BlogPost extends React.Component {
componentDidMount() {}

render() {
const { hasError, isLoading, page, posts } = this.props;
const { isLoading, page } = this.props;
return (
<div>
{!isLoading &&
page.node && (
<Layout>
<Head>
<title>Tegner bryggers - {page.node.title}</title>
<meta
name="description"
content={textRenderer(page.node.body).slice(0, 150) + '…'}
/>
</Head>
<Layout name={page.node.batch}>
<PageHead
title={'Tegner bryggers -' + page.node.title}
description={textRenderer(page.node.body).slice(0, 150) + '…'}
/>
<article>
<header className="post-header">
<h1>{page.node.title}</h1>
Expand Down Expand Up @@ -84,7 +78,7 @@ class BlogPost extends React.Component {
}

const BlogPostContainer = withPhenomicApi(BlogPost, props => ({
page: query({ path: 'content/posts', id: props.params.splat })
page: query({ path: 'posts', id: props.params.splat })
}));

export { BlogPostContainer };
36 changes: 8 additions & 28 deletions src/Home.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import React from 'react';
import Head from 'react-helmet';
import { Router, Route, browserHistory, Link } from 'react-router';
import {
createApp,
withPhenomicApi,
query,
BodyRenderer,
textRenderer
} from '@phenomic/preset-react-app/lib/client';
import { Link } from 'react-router';
import { withPhenomicApi, query } from '@phenomic/preset-react-app/lib/client';
import { Layout } from './Layout';
import { BigLink } from './BigLink';
import { PageHead } from './PageHead';

const Home = ({ isLoading, posts }) => (
<div>
{!isLoading && (
<Layout name="home">
<Head>
<title>Tegner Bryggers</title>
<meta
name="description"
content="Tegner bryggers - Hjemmebryggeri, log over bryg"
/>
</Head>
<PageHead
title="Tegner bryggers"
description="Tegner bryggers - Hjemmebryggeri, log over bryg"
/>
<div className="home-content">
<h1>Tegner bryggers</h1>
<p>Hjemmebryggeri på Amager, startet April 2017</p>
Expand Down Expand Up @@ -58,18 +49,7 @@ const Home = ({ isLoading, posts }) => (
);

const HomeContainer = withPhenomicApi(Home, props => ({
posts: query({ path: 'content/posts', limit: 5, after: props.params.after })
posts: query({ path: 'posts', limit: 5, after: props.params.after })
}));

export { HomeContainer };

// <div>
// {posts.node &&
// posts.node.next && (
// <Link to={`/after/${posts.node.next}/`}>Older posts</Link>
// )}
// {posts.node &&
// posts.node.previous && (
// <Link to={posts.node.previousPageIsFirst ? `/` : `/after/${posts.node.previous}/`}>Newer posts</Link>
// )}
// </div>
7 changes: 0 additions & 7 deletions src/Layout.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import React from 'react';
import Head from 'react-helmet';
import { Logo } from './Logo';
// import '../public/css/style.css'
import { MenuContainer } from './Menu';
import { Styling } from './Styling';

const Layout = props => {
return (
<div className="blog page-container">
<Head>
<html lang="en" /> {/* this is valid react-helmet usage! */}
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/favicon.png" rel="icon" type="image/png" />
</Head>
<header className="header">
<a href="/" className="header-logo">
<Logo />
Expand Down
33 changes: 6 additions & 27 deletions src/Menu.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@
import React from 'react';
import Head from 'react-helmet';
import { Router, Route, browserHistory, Link } from 'react-router';
import {
createApp,
withPhenomicApi,
query,
BodyRenderer,
textRenderer
} from '@phenomic/preset-react-app/lib/client';

const MenuToggler = function(ev, obj) {
if (ev) {
ev.preventDefault();
ev.stopPropagation();
}

let menuElement = document.getElementById('menu');
if (menuElement !== null) {
if (obj && obj.onlyClose) {
menuElement.classList.remove('menu--opened');
} else {
menuElement.classList.toggle('menu--opened');
}
}
};
import { Link } from 'react-router';
import { withPhenomicApi, query } from '@phenomic/preset-react-app/lib/client';

class Menu extends React.Component {
constructor(props) {
super(props);
console.log('menu props', props);
this.state = {
closed: true
};
Expand All @@ -39,7 +17,8 @@ class Menu extends React.Component {
}

componentWillReceiveProps(nextProps) {
if (this.props.name !== nextProps.name) {
console.log('componentWillReceiveProps', nextProps, this.props);
if (this.props.postName !== nextProps.postName) {
this.setState({ closed: true });
}
}
Expand Down Expand Up @@ -104,7 +83,7 @@ class Menu extends React.Component {
}

const MenuContainer = withPhenomicApi(Menu, props => ({
posts: query({ path: 'content/posts', limit: 12 })
posts: query({ path: 'posts', limit: 12 })
}));

export { MenuContainer, Menu };
24 changes: 24 additions & 0 deletions src/PageHead.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import Head from 'react-helmet';
import { Styling } from './Styling';

export class PageHead extends React.Component {
constructor(props) {
super(props);
}

render() {
const { title, description } = this.props;
return (
<Head>
<html lang="da" /> {/* this is valid react-helmet usage! */}
<title>{title}</title>
<meta name="description" content={description} />
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/favicon.png" rel="icon" type="image/png" />
<Styling />
</Head>
);
}
}
21 changes: 9 additions & 12 deletions src/PostListContainer.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import React from 'react';
import Head from 'react-helmet';
import { Router, Route, browserHistory, Link } from 'react-router';
import {
createApp,
withPhenomicApi,
query,
BodyRenderer,
textRenderer
} from '@phenomic/preset-react-app/lib/client';
import { Link } from 'react-router';
import { withPhenomicApi, query } from '@phenomic/preset-react-app/lib/client';
import { Layout } from './Layout';
import { BigLink } from './BigLink';
import { MenuToggler } from './Menu';
import { PageHead } from './PageHead';

const PostList = ({ hasError, isLoading, posts }) => {
if (hasError) {
return <PageError error={page.error} />;
}

return (
<Layout>
<Layout name="allposts">
<PageHead
title="Tegner Bryggers - Alle indlæg"
description="Liste over alle indlæg"
/>
<h1 className="list-head">Alle indlæg</h1>
{isLoading && 'Loading...'}
{!isLoading &&
Expand Down Expand Up @@ -54,7 +51,7 @@ const PostList = ({ hasError, isLoading, posts }) => {
};

const PostListContainer = withPhenomicApi(PostList, props => ({
posts: query({ path: 'content/posts', limit: 12, after: props.params.after })
posts: query({ path: 'posts', limit: 12, after: props.params.after })
}));

export { PostListContainer };
Loading

0 comments on commit b5bce11

Please sign in to comment.