Reputation: 101
I've been trying to get the gatsby sitemap plugin to work for awhile now and I cannot figure out what I'm doing wrong here. First I couldnt pull the site.siteMetadata.siteTitle
so I had to set it with a function. Now, I'm having trouble getting pages added to the sitemap. Yes, I've tested the query in Graphiql multiple times and it works.
I am getting the following error and below it is my sitemap config (just trying to get the pages to work for now):
"gatsby-plugin-sitemap" threw an error while running the onPostBuild lifecycle:
Syntax Error: Expected Name, found <EOF>.
40 | output = _ref2.output, entryLimit = _ref2.entryLimit, query = _ref2.query, excludes =
_ref2.excludes, resolveSiteUrl = _ref2.resolveSiteUrl, resolvePagePath = _ref2.resolvePagePath,
resolvePages = _ref2.resolvePages, filterPages = _ref2.filterPages, serialize = _ref2.serialize;
41 | _context.next = 4;
> 42 | return graphql(query);
| ^
43 |
44 | case 4:
45 | _yield$graphql = _context.sent;
File: node_modules/gatsby-plugin-sitemap/gatsby-node.js:42:20
{
resolve: `gatsby-plugin-sitemap`,
options: {
query: `{
site {
siteMetadata {
siteUrl
}
}
allSitePage {
nodes {
path
}
}
allMarkdownRemark {
edges {
node {
frontmatter {
slug
}
}
}
}`,
resolveSiteUrl: siteUrl,
resolvePages: ({ allSitePage: {nodes: allPages} }) => {
return allPages.map(page => {
return { ...page }
})
},
serialize: ({ path }) => {
return {
url: path,
priority: 0.7,
};
},
},
},
Upvotes: 0
Views: 700
Reputation: 29305
I think you are missing a }
at the end of your query:
{
resolve: `gatsby-plugin-sitemap`,
options: {
query: `{
site {
siteMetadata {
siteUrl
}
}
allSitePage {
nodes {
path
}
}
allMarkdownRemark {
edges {
node {
frontmatter {
slug
}
}
}
}
}`,
resolveSiteUrl: siteUrl,
resolvePages: ({ allSitePage: {nodes: allPages} }) => {
return allPages.map(page => {
return { ...page }
})
},
serialize: ({ path }) => {
return {
url: path,
priority: 0.7,
};
},
},
},
Because the query object it's not properly formatted, it throws the syntax (<EOF>
, end-of-file) exception.
The rest should work alone.
Upvotes: 1