Skip to content

Commit

Permalink
Delete news category page not need anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
viphan007 committed Nov 21, 2023
1 parent b578a9f commit eb94567
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
16 changes: 7 additions & 9 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,18 @@ exports.createPages = async ({ graphql, actions }) => {
const newsCategories = []
const result = await graphql(`
{
allCategories: allContentfulNewsCategory {
edges {
node {
contentful_id
name
}
allCategories: allContentfulNewsCategory(filter: {name: {regex: "/^(?!.*(?:Latest|example)).*$/"}}) {
nodes {
contentful_id
name
}
}
}
`)
if (result.data && result.data.allCategories) {
result.data.allCategories.edges.forEach(cat => {
if (cat.node.name && !cat.node.name.includes('example')) {
newsCategories.push(cat.node.name.toLowerCase())
result.data.allCategories.nodes.forEach(cat => {
if (cat.name) {
newsCategories.push(cat.name.toLowerCase())
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const ContentfulModuleContainer = props => {
previewMode ? modules[0].title : modules[0].contentful_id
}
isTabParam={isCategoryTab}
></TabWrapper>
/>
) : null}
{!isTab && modules && modules.length && (
<Modules
Expand Down
7 changes: 6 additions & 1 deletion src/components/Tab/TabHeaderItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ const TabHeaderItem = props => {
}

if (isTabParam) {
const newsCategory = encodeURIComponent(lowerCase(label))
let newsCategoryUrl = `/news/${newsCategory}/`
if (newsCategory === 'latest') {
newsCategoryUrl = '/news/'
}
return (
<Link to={`/news/${encodeURIComponent(lowerCase(label))}/`}>
<Link to={newsCategoryUrl}>
<Item typeLayout={typeLayout} active={activeId === id}>
{label}
</Item>
Expand Down

0 comments on commit eb94567

Please sign in to comment.