Skip to content

Commit

Permalink
chore: format & monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
xueqingxiao committed Mar 29, 2019
1 parent e11e02c commit 1c054e0
Show file tree
Hide file tree
Showing 31 changed files with 688 additions and 374 deletions.
6 changes: 3 additions & 3 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// custom typefaces
import "typeface-montserrat"
import "typeface-merriweather"
import "prismjs/themes/prism-tomorrow.css"
import 'typeface-montserrat';
import 'typeface-merriweather';
import 'prismjs/themes/prism-tomorrow.css';
20 changes: 14 additions & 6 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ module.exports = {
{
resolve: `gatsby-remark-prismjs`,
options: {
classPrefix: "language-",
classPrefix: 'language-',
inlineCodeMarker: null,
showLineNumbers: false,
noInlineHighlight: false,
}
},
},
`gatsby-remark-copy-linked-files`,
`gatsby-remark-smartypants`,
Expand Down Expand Up @@ -85,9 +85,17 @@ module.exports = {
path: `${__dirname}/src/data`,
},
},
{
resolve: 'gatsby-plugin-sentry',
options: {
dsn: 'https://2bac2527d53d4dad8db23f741054f787@sentry.io/1426625',
environment: process.env.NODE_ENV,
enabled: (() => ['production', 'stage'].indexOf(process.env.NODE_ENV) !== -1)(),
},
},
],
mapping: {
"MarkdownRemark.frontmatter.authors": `AuthorsYaml`,
"MarkdownRemark.frontmatter.translators": `AuthorsYaml`,
}
}
'MarkdownRemark.frontmatter.authors': `AuthorsYaml`,
'MarkdownRemark.frontmatter.translators': `AuthorsYaml`,
},
};
39 changes: 18 additions & 21 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
const path = require(`path`)
const { createFilePath } = require(`gatsby-source-filesystem`)
const path = require(`path`);
const { createFilePath } = require(`gatsby-source-filesystem`);

exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions
const { createPage } = actions;

const blogPost = path.resolve(`./src/templates/blog-post.js`)
const blogPost = path.resolve(`./src/templates/blog-post.js`);
return graphql(
`
{
allMarkdownRemark(
sort: { fields: [frontmatter___date], order: DESC }
limit: 1000
) {
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }, limit: 1000) {
edges {
node {
fields {
Expand All @@ -27,15 +24,15 @@ exports.createPages = ({ graphql, actions }) => {
`
).then(result => {
if (result.errors) {
throw result.errors
throw result.errors;
}

// Create blog posts pages.
const posts = result.data.allMarkdownRemark.edges
const posts = result.data.allMarkdownRemark.edges;

posts.forEach((post, index) => {
const previous = index === posts.length - 1 ? null : posts[index + 1].node
const next = index === 0 ? null : posts[index - 1].node
const previous = index === posts.length - 1 ? null : posts[index + 1].node;
const next = index === 0 ? null : posts[index - 1].node;

createPage({
path: post.node.fields.slug,
Expand All @@ -45,22 +42,22 @@ exports.createPages = ({ graphql, actions }) => {
previous,
next,
},
})
})
});
});

return null
})
}
return null;
});
};

exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
const { createNodeField } = actions;

if (node.internal.type === `MarkdownRemark`) {
const value = createFilePath({ node, getNode })
const value = createFilePath({ node, getNode });
createNodeField({
name: `slug`,
node,
value,
})
});
}
}
};
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"gatsby-plugin-manifest": "^2.0.25",
"gatsby-plugin-offline": "^2.0.25",
"gatsby-plugin-react-helmet": "^3.0.11",
"gatsby-plugin-sentry": "^1.0.1",
"gatsby-plugin-sharp": "^2.0.32",
"gatsby-plugin-typography": "^2.2.10",
"gatsby-remark-copy-linked-files": "^2.0.11",
Expand Down Expand Up @@ -51,8 +52,13 @@
"scripts": {
"now-build": "yarn build",
"build": "gatsby build",
"format": "prettier --write src/**/*.{js,jsx}",
"format": "prettier --write src/**/*.{js,jsx,yml,json} gatsby-*.js",
"start": "gatsby develop",
"serve": "gatsby serve"
},
"prettier": {
"printWidth": 120,
"singleQuote": true,
"trailingComma": "es5"
}
}
4 changes: 2 additions & 2 deletions src/components/bio.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* See: https://www.gatsbyjs.org/docs/static-query/
*/

import React from "react";
import { StaticQuery, graphql } from "gatsby";
import React from 'react';
import { StaticQuery, graphql } from 'gatsby';

function Bio({ children }) {
return (
Expand Down
27 changes: 6 additions & 21 deletions src/components/frontmatter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import React from 'react';

const Frontmatter = ({ frontmatter }) => (
<>
{frontmatter.date}
&nbsp;&nbsp;
{frontmatter.authors && frontmatter.authors.length > 0 ? "作者:" : null}
{frontmatter.authors && frontmatter.authors.length > 0 ? '作者:' : null}
{frontmatter.authors &&
frontmatter.authors.map((author, index) => (
<span key={author.id}>
Expand All @@ -15,33 +15,18 @@ const Frontmatter = ({ frontmatter }) => (
{author.name}
</a>
)}
{index < frontmatter.authors.length - 1 ? (
<span>,&nbsp;</span>
) : (
<span>&nbsp;</span>
)}
{index < frontmatter.authors.length - 1 ? <span>,&nbsp;</span> : <span>&nbsp;</span>}
</span>
))}
&nbsp;&nbsp;
{frontmatter.translators && frontmatter.translators.length > 0
? "译者:"
: null}
{frontmatter.translators && frontmatter.translators.length > 0 ? '译者:' : null}
{frontmatter.translators &&
frontmatter.translators.map((translator, index) => (
<span key={translator.id}>
<a
target="_blank"
rel="noopener noreferrer"
key={translator.id}
href={translator.social}
>
<a target="_blank" rel="noopener noreferrer" key={translator.id} href={translator.social}>
{translator.name}
</a>
{index < frontmatter.translators.length - 1 ? (
<span>,&nbsp;</span>
) : (
<span>&nbsp;</span>
)}
{index < frontmatter.translators.length - 1 ? <span>,&nbsp;</span> : <span>&nbsp;</span>}
</span>
))}
</>
Expand Down
17 changes: 8 additions & 9 deletions src/components/layout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Link } from "gatsby";
import React from 'react';
import { Link } from 'gatsby';

import { rhythm, scale } from "../utils/typography";
import { rhythm, scale } from '../utils/typography';

class Layout extends React.Component {
render() {
Expand All @@ -15,14 +15,14 @@ class Layout extends React.Component {
style={{
...scale(1.5),
marginBottom: rhythm(1.5),
marginTop: 0
marginTop: 0,
}}
>
<Link
style={{
boxShadow: `none`,
textDecoration: `none`,
color: `inherit`
color: `inherit`,
}}
to={`/`}
>
Expand All @@ -37,7 +37,7 @@ class Layout extends React.Component {
style={{
boxShadow: `none`,
textDecoration: `none`,
color: `inherit`
color: `inherit`,
}}
to={`/`}
>
Expand All @@ -52,15 +52,14 @@ class Layout extends React.Component {
marginLeft: `auto`,
marginRight: `auto`,
maxWidth: rhythm(36),
padding: `${rhythm(1.5)} ${rhythm(3 / 4)}`
padding: `${rhythm(1.5)} ${rhythm(3 / 4)}`,
}}
>
<header>{header}</header>
<main>{children}</main>
<footer>
© {new Date().getFullYear()},{` `}
<a href="http://FENews.org">FENews</a>,
<a href="https://github.com/FENews">Github</a>
<a href="http://FENews.org">FENews</a>,<a href="https://github.com/FENews">Github</a>
</footer>
</div>
);
Expand Down
34 changes: 17 additions & 17 deletions src/components/seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* See: https://www.gatsbyjs.org/docs/use-static-query/
*/

import React from "react";
import PropTypes from "prop-types";
import Helmet from "react-helmet";
import { useStaticQuery, graphql } from "gatsby";
import React from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import { useStaticQuery, graphql } from 'gatsby';

function SEO({ description, lang, meta, keywords, title }) {
const { site } = useStaticQuery(
Expand All @@ -29,49 +29,49 @@ function SEO({ description, lang, meta, keywords, title }) {
return (
<Helmet
htmlAttributes={{
lang
lang,
}}
title={title}
titleTemplate={`%s | ${site.siteMetadata.title}`}
meta={[
{
name: `description`,
content: metaDescription
content: metaDescription,
},
{
property: `og:title`,
content: title
content: title,
},
{
property: `og:description`,
content: metaDescription
content: metaDescription,
},
{
property: `og:type`,
content: `website`
content: `website`,
},
{
name: `twitter:card`,
content: `summary`
content: `summary`,
},
{
name: `twitter:creator`,
content: site.siteMetadata.author
content: site.siteMetadata.author,
},
{
name: `twitter:title`,
content: title
content: title,
},
{
name: `twitter:description`,
content: metaDescription
}
content: metaDescription,
},
]
.concat(
keywords.length > 0
? {
name: `keywords`,
content: keywords.join(`, `)
content: keywords.join(`, `),
}
: []
)
Expand All @@ -83,15 +83,15 @@ function SEO({ description, lang, meta, keywords, title }) {
SEO.defaultProps = {
lang: `en`,
meta: [],
keywords: []
keywords: [],
};

SEO.propTypes = {
description: PropTypes.string,
lang: PropTypes.string,
meta: PropTypes.array,
keywords: PropTypes.arrayOf(PropTypes.string),
title: PropTypes.string.isRequired
title: PropTypes.string.isRequired,
};

export default SEO;
2 changes: 1 addition & 1 deletion src/data/authors/danielhe.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id: danielhe
avatar: https://avatars3.githubusercontent.com/u/444990?s=460&v=4
name: Daniel He
social: https://github.com/danielhe
social: https://github.com/danielhe
2 changes: 1 addition & 1 deletion src/data/authors/fanyongfeng.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id: fanyongfeng
avatar: https://avatars2.githubusercontent.com/u/15905834?s=460&v=4
name: 樊勇锋
social: https://github.com/fanyongfeng
social: https://github.com/fanyongfeng
2 changes: 1 addition & 1 deletion src/data/authors/fengshenhai-0727.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id: fengshenhai-0727
avatar: https://avatars2.githubusercontent.com/u/23276885?s=460&v=4
name: TF
social: https://github.com/fengshenhai-0727
social: https://github.com/fengshenhai-0727
2 changes: 1 addition & 1 deletion src/data/authors/gaearon.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id: gaearon
avatar: https://avatars1.githubusercontent.com/u/810438?s=460&v=4
name: Dan Abramov
social: https://github.com/gaearon
social: https://github.com/gaearon
2 changes: 1 addition & 1 deletion src/data/authors/hearingguo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id: hearingguo
avatar: https://avatars2.githubusercontent.com/u/7402309?s=460&v=4
name: highya
social: https://github.com/hearingguo
social: https://github.com/hearingguo
2 changes: 1 addition & 1 deletion src/data/authors/hooraybuffer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id: hooraybuffer
avatar: https://v8.dev/_img/avatars/peter-marshall@2x.jpg
name: Peter Marshall
social: https://twitter.com/hooraybuffer
social: https://twitter.com/hooraybuffer
Loading

0 comments on commit 1c054e0

Please sign in to comment.