Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amp to pwa #1

Merged
merged 6 commits into from Feb 17, 2019
Merged
Diff settings

Always

Just for now

fix(blog): change article path

  • Loading branch information...
tomoyukikashiro committed Feb 13, 2019
commit c29e8be855a88a1a5b29879e0647d6cb3bd1be89
Copy path View file
@@ -53,7 +53,48 @@ module.exports = {
//trackingId: `ADD YOUR TRACKING ID HERE`,
},
},
`gatsby-plugin-feed`,
{
resolve: `gatsby-plugin-feed`,
options: {
feeds: [
{
serialize: ({ query: { site, allMarkdownRemark } }) => {
return allMarkdownRemark.edges.map(edge => {
return Object.assign({}, edge.node.frontmatter, {
description: edge.node.excerpt,
date: edge.node.frontmatter.date,
url: site.siteMetadata.siteUrl + 'posts' + edge.node.fields.slug,
guid: site.siteMetadata.siteUrl + 'posts' + edge.node.fields.slug,
custom_elements: [{ "content:encoded": edge.node.html }],
})
})
},
query: `
{
allMarkdownRemark(
limit: 1000,
sort: { order: DESC, fields: [frontmatter___date] }
) {
edges {
node {
excerpt
html
fields { slug }
frontmatter {
title
date
}
}
}
}
}
`,
output: "/rss.xml",
title: "Gatsby RSS Feed",
}
]
}
},
{
resolve: `gatsby-plugin-manifest`,
options: {
Copy path View file
@@ -38,7 +38,7 @@ exports.createPages = ({ graphql, actions }) => {
const next = index === 0 ? null : posts[index - 1].node

createPage({
path: post.node.fields.slug,
path: `posts${post.node.fields.slug}`,
component: blogPost,
context: {
slug: post.node.fields.slug,
@@ -3,20 +3,28 @@ import PropTypes from "prop-types"
import Helmet from "react-helmet"
import { StaticQuery, graphql } from "gatsby"

function SEO({ description, lang, meta, keywords, title }) {
function SEO({ description, lang, meta, keywords, title, slug = ''}) {
return (
<StaticQuery
query={detailsQuery}
render={data => {
const metaDescription =
description || data.site.siteMetadata.description
const siteUrl = data.site.siteMetadata.siteUrl
const path = slug ? `posts${slug}` : slug
return (
<Helmet
htmlAttributes={{
lang,
}}
title={title}
titleTemplate={`%s | ${data.site.siteMetadata.title}`}
link={[
{
rel: 'canonical',
href: `${siteUrl}${path}`
}
]}
meta={[
{
name: `description`,
@@ -90,6 +98,7 @@ const detailsQuery = graphql`
title
description
author
siteUrl
}
}
}
Copy path View file
@@ -28,7 +28,7 @@ class BlogIndex extends React.Component {
marginBottom: rhythm(1 / 4),
}}
>
<Link style={{ boxShadow: `none` }} to={node.fields.slug}>
<Link style={{ boxShadow: `none` }} to={`/posts${node.fields.slug}`}>
{title}
</Link>
</h3>
@@ -10,11 +10,11 @@ class BlogPostTemplate extends React.Component {
render() {
const post = this.props.data.markdownRemark
const siteTitle = this.props.data.site.siteMetadata.title
const { previous, next } = this.props.pageContext
const { previous, next, slug } = this.props.pageContext

return (
<Layout location={this.props.location} title={siteTitle}>
<SEO title={post.frontmatter.title} description={post.excerpt} />
<SEO title={post.frontmatter.title} description={post.excerpt} slug={slug} />
<h1>{post.frontmatter.title}</h1>
<p
style={{
@@ -45,14 +45,14 @@ class BlogPostTemplate extends React.Component {
>
<li>
{previous && (
<Link to={previous.fields.slug} rel="prev">
<Link to={`/posts${previous.fields.slug}`} rel="prev">
← {previous.frontmatter.title}
</Link>
)}
</li>
<li>
{next && (
<Link to={next.fields.slug} rel="next">
<Link to={`/posts${next.fields.slug}`} rel="next">
{next.frontmatter.title} →
</Link>
)}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.