Skip to content

Commit

Permalink
🐛 Issue #24: Link Description is for Gatsby
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Sep 15, 2020
1 parent 05ccedc commit 58887f7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions configs/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = {
pathPrefix: `${process.env.GATSBY_SITE_PATH_PREFIX}`,
siteMetadata: {
title: `${process.env.GATSBY_SOURCE_TITLE}`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `@gatsbyjs`,
description: ``,
author: `@adobedevs`,
},
plugins: [
`gatsby-plugin-react-helmet`,
Expand Down
16 changes: 13 additions & 3 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const searchTree = (theObject, matchingFilename) => {

const readManifest = async graphql => {
let pages = []
let description = ""
try {
let { data } = await graphql(`
query {
Expand All @@ -108,6 +109,7 @@ const readManifest = async graphql => {
const object = JSON.parse(fs.readFileSync(path, "utf8"))
if (object.view_type === "mdbook") {
pages = object.pages
description = object.description
}
})
}
Expand All @@ -116,7 +118,7 @@ const readManifest = async graphql => {
console.log("Could not read the manifest")
}

return pages
return { pages, description }
}

const gitRepoInfo = () => {
Expand Down Expand Up @@ -197,7 +199,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
const openapiTemplate = path.resolve(`src/templates/openapiTemplate.js`)
const indexTemplate = path.resolve(`src/templates/indexTemplate.js`)

const pages = await readManifest(graphql)
const { pages, description } = await readManifest(graphql)
const gitRemote = gitRepoInfo(graphql)

try {
Expand Down Expand Up @@ -230,6 +232,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
slug: node.fields.slug,
id: node.fields.id,
seo: seo,
description: description,
gitRemote: gitRemote,
pages: pages,
},
Expand All @@ -242,6 +245,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
slug: node.fields.slug,
id: node.fields.id,
seo: seo,
description: description,
gitRemote: gitRemote,
pages: pages,
},
Expand Down Expand Up @@ -280,6 +284,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
object,
filepath,
seo,
description,
gitRemote,
pages
)
Expand Down Expand Up @@ -316,6 +321,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
object,
filepath,
seo,
description,
gitRemote,
pages
)
Expand Down Expand Up @@ -367,6 +373,7 @@ const createOpenApiPage = (
object,
filepath,
seo,
description,
gitRemote,
pages
) => {
Expand All @@ -376,7 +383,9 @@ const createOpenApiPage = (
switch (environment) {
case "production":
if (filepath.lastIndexOf("gatsby-source-git/") > -1) {
slug = filepath.substring(filepath.lastIndexOf("gatsby-source-git/") + 18)
slug = filepath.substring(
filepath.lastIndexOf("gatsby-source-git/") + 18
)
}
break
case "development":
Expand Down Expand Up @@ -435,6 +444,7 @@ const createOpenApiPage = (
context: {
spec: object,
seo: seo,
description: description,
gitRemote: gitRemote,
pages: pages,
},
Expand Down
5 changes: 4 additions & 1 deletion src/templates/markdownTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ const MarkdownTemplate = props => {

return (
<DocLayout>
<SEO title={props.pageContext.seo} />
<SEO
title={props.pageContext.seo}
description={props.pageContext.description}
/>
<Grid>
<GridNav>
<SiteNav
Expand Down
2 changes: 1 addition & 1 deletion src/templates/openapiTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
const OpenApiTemplate = ({ pageContext, location }) => {
return (
<DocLayout>
<SEO title={pageContext.seo} />
<SEO title={pageContext.seo} description={pageContext.description} />
<OpenApiGrid>
<OpenApiGridNav>
<SiteNav
Expand Down
5 changes: 4 additions & 1 deletion src/templates/recipeTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ const MarkdownTemplate = props => {

return (
<DocLayout>
<SEO title={props.pageContext.seo} />
<SEO
title={props.pageContext.seo}
description={props.pageContext.description}
/>
<Grid>
<GridNav>
<SiteNav
Expand Down

0 comments on commit 58887f7

Please sign in to comment.