Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Sean/update cms endpoint #2001

Merged
1 commit merged into from Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ module.exports = {
{
resolve: '@directus/gatsby-source-directus',
options: {
url: `https://amammustofa.com`,
url: `https://cms.deriv.com`,
dev: {
refresh: '5s',
},
Expand Down
69 changes: 35 additions & 34 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,40 +251,41 @@ exports.onCreateWebpackConfig = ({ actions, getConfig }, { ...options }) => {
})
}

exports.createPages = async ({ reporter, actions, graphql }) => {
const { createPage } = actions
const articleTemplate = path.resolve(__dirname, 'src/templates/article.js')
// TODO: To be updated to the new shape of the API of the new endpoint
// exports.createPages = async ({ reporter, actions, graphql }) => {
// const { createPage } = actions
// const articleTemplate = path.resolve(__dirname, 'src/templates/article.js')

// Query our published articles
const result = await graphql(`
query MyQuery {
directus {
articles(filter: { status: { _eq: "published" } }) {
article_title
article_url
translations {
article_title
languages_id
}
}
}
}
`)
// Query our published articles
// const result = await graphql(`
// query MyQuery {
// directus {
// articles(filter: { status: { _eq: "published" } }) {
// article_title
// article_url
// translations {
// article_title
// languages_id
// }
// }
// }
// }
// `)

if (result.errors) {
reporter.panic(result.errors)
}
const articles = result.data.directus.articles
// if (result.errors) {
// reporter.panic(result.errors)
// }
// const articles = result.data.directus.articles

articles.forEach((article) => {
createPage({
path: `/blog/articles/${article.article_url}`,
component: articleTemplate,
context: {
locale: 'en',
pathname: `/blog/articles/${article.article_url}`,
slug: article.article_url,
},
})
})
}
// articles.forEach((article) => {
// createPage({
// path: `/blog/articles/${article.article_url}`,
// component: articleTemplate,
// context: {
// locale: 'en',
// pathname: `/blog/articles/${article.article_url}`,
// slug: article.article_url,
// },
// })
// })
// }