Skip to content

Commit

Permalink
Update feed and javascript transform example sites (#6224)
Browse files Browse the repository at this point in the history
* Update feed example to Gatsby v2

* Update using-javascript-transforms example to Gatsby v2

* Fix eslint warnings

* Tidy up package.json
  • Loading branch information
m-allanson authored and pieh committed Jun 29, 2018
1 parent c1d86bc commit 52c3354
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 123 deletions.
8 changes: 0 additions & 8 deletions examples/feed/.eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions examples/feed/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RSS Feed Example

https://feed.gatsbyjs.org

Gatsby example site demonstrating how to use the RSS Feed generator plugin.

Note that the RSS Feed will only be generated when running `gatsby build`.
14 changes: 9 additions & 5 deletions examples/feed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
"version": "1.0.0",
"author": "Nicholas Young <[email protected]>",
"dependencies": {
"gatsby": "latest",
"gatsby-source-filesystem": "latest",
"gatsby-transformer-remark": "latest",
"gatsby-plugin-feed": "latest"
"gatsby": "next",
"gatsby-plugin-feed": "next",
"gatsby-source-filesystem": "next",
"gatsby-transformer-remark": "next",
"react": "^16.4.1",
"react-dom": "^16.4.1"
},
"keywords": ["gatsby"],
"keywords": [
"gatsby"
],
"license": "MIT",
"main": "index.js",
"scripts": {
Expand Down
33 changes: 0 additions & 33 deletions examples/feed/src/html.js

This file was deleted.

7 changes: 0 additions & 7 deletions examples/feed/src/layouts/index.js

This file was deleted.

7 changes: 2 additions & 5 deletions examples/feed/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import React from "react"

const IndexRoute = () => (
<div>
<p>
Welcome to the GatsbyJS RSS Demo.
<a href="/rss.xml">Click here</a>
to see the generated RSS Feed.
</p>
<p> Welcome to the GatsbyJS RSS Demo.</p>
<p><a href="/rss.xml">Click here</a> to see the generated RSS Feed.</p>
</div>
)

Expand Down
25 changes: 11 additions & 14 deletions examples/using-javascript-transforms/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{
"name": "gatsby-example-using-javascript-transforms",
"version": "1.0.0",
"version": "2.0.0",
"description": "example site and blog",
"main": "index.js",
"scripts": {
"develop": "node_modules/.bin/gatsby develop",
"dev:hard": "rm -rf .cache && rm -rf public && npm run develop",
"build": "npm run clean & .\\node_modules\\.bin\\gatsby build",
"serve": "node_modules/.bin/gatsby serve",
"clean:public": "rm -rf public & mkdir public",
"clean": "npm run clean:public",
"lint": "./node_modules/.bin/eslint --ext .js,.jsx --ignore-pattern public .",
"develop": "gatsby develop",
"build": "gatsby build",
"serve": "gatsby serve",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
Expand All @@ -26,13 +22,14 @@
"dependencies": {
"bulma": "0.4.2",
"d3": "4.9.1",
"gatsby": "latest",
"gatsby-plugin-sass": "^1.0.16",
"gatsby-remark-prismjs": "latest",
"gatsby-source-filesystem": "latest",
"gatsby-transformer-javascript-frontmatter": "latest",
"gatsby-transformer-remark": "latest",
"gatsby": "next",
"gatsby-plugin-sass": "next",
"gatsby-remark-prismjs": "next",
"gatsby-source-filesystem": "next",
"gatsby-transformer-javascript-frontmatter": "next",
"gatsby-transformer-remark": "next",
"moment": "^2.14.1",
"node-sass": "^4.9.0",
"normalize.css": "^7.0.0",
"prismjs": "^1.13.0",
"prop-types": "^15.5.8",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from "react"
import BlogPostChrome from "../../components/BlogPostChrome"
import { findDOMNode } from "react-dom"
var d3 = require(`d3`)

// this is one method to export data and make it usable elsewhere
exports.frontmatter = {
export const frontmatter = {
title: `Choropleth on d3v4`,
written: `2017-03-09`,
updated: `2017-04-28`,
Expand All @@ -15,10 +14,6 @@ exports.frontmatter = {
}

class choroplethBase extends React.Component {
constructor(props) {
super(props)
}

componentDidMount() {
this.d3Node = d3.select(`div#states`)
let measurements = {
Expand Down Expand Up @@ -127,7 +122,7 @@ average: tooltip, path fill

let states = svg.selectAll(`path.states`).data(data)

let drawStates = states
states
.enter()
.append(`path`)
.attr(`class`, `state`)
Expand Down Expand Up @@ -173,6 +168,7 @@ let mouseOut = () => {
.style(`opacity`, 0)
}

// eslint-disable-next-line no-unused-vars
function scale(scaleFactor, width, height) {
return d3.geoTransform({
point: function(x, y) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react"
import BlogPostChrome from "../../components/BlogPostChrome"
import { findDOMNode } from "react-dom"
var d3 = require(`d3`)

// this is an additional method to export data and make it usable elsewhere
Expand All @@ -14,10 +13,6 @@ export const frontmatter = {
}

class choroplethAltBase extends React.Component {
constructor(props) {
super(props)
}

componentDidMount() {
this.d3Node = d3.select(`div#states`)
let measurements = {
Expand Down Expand Up @@ -126,7 +121,7 @@ average: tooltip, path fill

let states = svg.selectAll(`path.states`).data(data)

let drawStates = states
states
.enter()
.append(`path`)
.attr(`class`, `state`)
Expand Down Expand Up @@ -172,6 +167,7 @@ let mouseOut = () => {
.style(`opacity`, 0)
}

// eslint-disable-next-line no-unused-vars
function scale(scaleFactor, width, height) {
return d3.geoTransform({
point: function(x, y) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from "react"
import { Link } from "gatsby"
import Helmet from "react-helmet"
import moment from "moment"

import MasterLayout from "./master"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import MasterLayout from "./master"

class InsetPageLayout extends React.Component {
render() {
const siteMetadata = this.props.data.site

return (
<div className="PageTemplate">
<MasterLayout {...this.props}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react"
import * as PropTypes from "prop-types"
import Helmet from "react-helmet"
import "../../static/css/base.scss"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
import React from "react"
import Helmet from "react-helmet"
import moment from "moment"

class PostPublished extends React.Component {
render() {
const frontmatter = this

let published
if (frontmatter.updated === null) {
var published = (
<div className="date-published">
<p>
<em>
published {moment(frontmatter.written).format(`D MMM YYYY`)}
</em>
</p>
</div>
published = (
<em>`published`{moment(frontmatter.written).format(`D MMM YYYY`)}</em>
)
} else {
var published = (
<div className="date-published">
<p>
<em>
originally published{` `}
{moment(frontmatter.written).format(`D MMM YYYY`)} and updated{` `}
{moment(frontmatter.updated).format(`D MMM YYYY`)}
</em>
</p>
</div>
published = (
<em>
{`originally published `}
{moment(frontmatter.written).format(`D MMM YYYY`)}
{` and updated `}
{moment(frontmatter.updated).format(`D MMM YYYY`)}
</em>
)
}

return <div className="container content">{published}</div>
return (
<div className="container content">
<div className="date-published">
<p>{published}</p>
</div>
</div>
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import SiteLinks from "../SiteLinks"

class SiteSidebar extends React.Component {
render() {
const isHome = this.props.location.pathname === `/`
const { siteMetadata } = this.props.data.site
// TODO, deal with image more nice like

Expand All @@ -14,7 +13,10 @@ class SiteSidebar extends React.Component {
<div className="card-image">
<Link to={`/`}>
<figure className="image">
<img src="https://camo.githubusercontent.com/ac31ac54c2013850b0fb8a3a4926f4718a398fb3/68747470733a2f2f7777772e6761747362796a732e6f72672f6d6f6e6f6772616d2e737667" />
<img
src="https://camo.githubusercontent.com/ac31ac54c2013850b0fb8a3a4926f4718a398fb3/68747470733a2f2f7777772e6761747362796a732e6f72672f6d6f6e6f6772616d2e737667"
alt="Gatsby logo"
/>
</figure>
</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from "react"
import Helmet from "react-helmet"
import SiteLinks from "../components/SiteLinks"
import InsetPageLayout from "../components/Layouts/insetPage"

exports.frontmatter = {
export const frontmatter = {
layoutType: `page`,
path: `/contact/`,
}
Expand Down
4 changes: 1 addition & 3 deletions examples/using-javascript-transforms/src/mainPages/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react"
import { Link } from "gatsby"
import Helmet from "react-helmet"
import sortBy from "lodash/sortBy"
import moment from "moment"
import InsetPageLayout from "../components/Layouts/insetPage"

exports.frontmatter = {
export const frontmatter = {
layoutType: `page`,
path: `/`,
}
Expand Down Expand Up @@ -116,7 +115,6 @@ export const pageQuery = graphql`
title
path
layoutType
parent
written
updated
category
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from "react"
import moment from "moment"
import BlogPostChrome from "../components/BlogPostChrome"

class mdBlogPost extends React.Component {
render() {
const { html, frontmatter } = this.props.data.markdownRemark
const { html } = this.props.data.markdownRemark

return (
<BlogPostChrome
Expand Down

0 comments on commit 52c3354

Please sign in to comment.