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.

feat: install directus #1882

Merged
6 commits merged into from
Jul 30, 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
11 changes: 10 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = {
],
serialize: ({ site, allSitePage }) =>
allSitePage.edges.map((edge) => {
const ignore_localized_regex = /careers/
const ignore_localized_regex = /careers|besquare|blog/
const path = edge.node.path
let priority = 0.7
const languages = Object.keys(language_config)
Expand Down Expand Up @@ -208,5 +208,14 @@ module.exports = {
offset: -100,
},
},
{
resolve: '@directus/gatsby-source-directus',
options: {
url: `https://amammustofa.com`,
dev: {
refresh: '5s',
},
},
},
],
}
50 changes: 41 additions & 9 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,13 @@ exports.onCreatePage = ({ page, actions }) => {
const { path, is_default } = language_config[lang]
const localized_path = is_default ? page.path : `${path}${page.path}`
const is_production = process.env.GATSBY_ENV === 'production'
const careers_regex = /^[a-z-]+\/careers\//g
const endpoint_regex = /^[a-z-]+\/endpoint\//g
const offline_plugin_regex = /^[a-z-]+\/offline-plugin-app-shell-fallback/g
const excluded_pages_regex =
/^[a-z-]+\/(careers|endpoint|offline-plugin-app-shell-fallback|besquare|blog)\//g

if (is_production) {
if (path === 'ach') return
}
if (
careers_regex.test(localized_path) ||
endpoint_regex.test(localized_path) ||
offline_plugin_regex.test(localized_path)
)
return
if (localized_path.match(excluded_pages_regex)) return

if (!translations_cache[lang]) {
const translation_json = require(`./src/translations/${lang}`)
Expand Down Expand Up @@ -256,3 +250,41 @@ exports.onCreateWebpackConfig = ({ actions, getConfig }, { ...options }) => {
},
})
}

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
}
}
}
}
`)

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,
},
})
})
}
Loading