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.

Nuri/feat : feature - new article template #2011

Merged
18 commits merged into from
Aug 26, 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
4 changes: 2 additions & 2 deletions 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|besquare|blog/
const ignore_localized_regex = /careers|besquare|blog|academy/
const path = edge.node.path
let priority = 0.7
const languages = Object.keys(language_config)
Expand Down Expand Up @@ -211,7 +211,7 @@ module.exports = {
{
resolve: 'gatsby-plugin-page-progress',
options: {
includePaths: [{ regex: '^/blog/article/' }],
includePaths: [{ regex: '^/academy/blog/posts/' }],
excludePaths: [],
height: 4,
prependToBody: true,
Expand Down
67 changes: 31 additions & 36 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exports.onCreatePage = ({ page, actions }) => {
const localized_path = is_default ? page.path : `${path}${page.path}`
const is_production = process.env.GATSBY_ENV === 'production'
const excluded_pages_regex =
/^[a-z-]+\/(careers|endpoint|offline-plugin-app-shell-fallback|besquare|blog)\//g
/^[a-z-]+\/(careers|endpoint|offline-plugin-app-shell-fallback|besquare|blog|academy)\//g

if (is_production) {
if (path === 'ach') return
Expand Down Expand Up @@ -252,40 +252,35 @@ exports.onCreateWebpackConfig = ({ actions, getConfig }, { ...options }) => {
}

// 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')
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
// Query our published articles
const result = await graphql(`
query MyQuery {
directus {
blog(filter: { status: { _eq: "published" } }) {
id
slug
}
}
}
`)

// 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,
// },
// })
// })
// }
if (result.errors) {
reporter.panic(result.errors)
}
const blog = result.data.directus.blog
blog.forEach((blog_post) => {
createPage({
path: `/academy/blog/posts/${blog_post.slug}`,
component: articleTemplate,
context: {
locale: 'en',
pathname: `/academy/blog/posts/${blog_post.slug}`,
slug: blog_post.slug,
},
})
})
}
11 changes: 11 additions & 0 deletions src/common/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,14 @@ export const redirectOpenLiveChatBox = (is_redirect) => {
navigate(live_chat_redirection_link, { replace: true })
}
}

export const convertDate = (date) => {
const newdate = new Date(date)
return (
newdate.toLocaleString('en', { day: 'numeric' }) +
' ' +
newdate.toLocaleString('en', { month: 'long' }) +
' ' +
newdate.toLocaleString('en', { year: 'numeric' })
)
}
Loading