Skip to content

Commit

Permalink
Removed unwanted static query compenents
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammed786 committed May 10, 2022
1 parent 92816ad commit 3131c6b
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 237 deletions.
53 changes: 52 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ exports.createPages = async ({ graphql, actions }) => {
const tagResults = await graphql(
`
{
allMarkdownRemark {
allMarkdownRemark(sort: { fields: frontmatter___date, order: DESC }) {
totalCount
edges {
node {
id
}
}
}
tagsGroup: allMarkdownRemark(limit: 2000) {
group(field: frontmatter___tags) {
fieldValue
}
}
markdownRemark(frontmatter: { pinned: { eq: true } }) {
id
}
}
`
)
Expand All @@ -41,8 +49,20 @@ exports.createPages = async ({ graphql, actions }) => {
{
allMarkdownRemark(
filter: { fields: { slug: { regex: "//engineering//" } } }
sort: { fields: frontmatter___date, order: DESC }
) {
totalCount
edges {
node {
id
}
}
}
markdownRemark(
frontmatter: { pinned: { eq: true } }
fields: { slug: { regex: "//engineering//" } }
) {
id
}
}
`
Expand All @@ -52,8 +72,20 @@ exports.createPages = async ({ graphql, actions }) => {
{
allMarkdownRemark(
filter: { fields: { slug: { regex: "//identity//" } } }
sort: { fields: frontmatter___date, order: DESC }
) {
totalCount
edges {
node {
id
}
}
}
markdownRemark(
frontmatter: { pinned: { eq: true } }
fields: { slug: { regex: "//identity//" } }
) {
id
}
}
`
Expand All @@ -63,8 +95,20 @@ exports.createPages = async ({ graphql, actions }) => {
{
allMarkdownRemark(
filter: { fields: { slug: { regex: "//growth//" } } }
sort: { fields: frontmatter___date, order: DESC }
) {
totalCount
edges {
node {
id
}
}
}
markdownRemark(
frontmatter: { pinned: { eq: true } }
fields: { slug: { regex: "//growth//" } }
) {
id
}
}
`
Expand Down Expand Up @@ -114,6 +158,12 @@ exports.createSchemaCustomization = ({ actions }) => {

const createTypePages = (type, results, createPage) => {
const postsPerPage = 6
let pinnedId = ""
if (results.data.markdownRemark) {
pinnedId = results.data.markdownRemark.id
} else {
pinnedId = results.data.allMarkdownRemark.edges[0].node.id
}
const total = results.data.allMarkdownRemark.totalCount
const numPages = Math.ceil(total / postsPerPage)
Array.from({ length: numPages }).forEach((_, i) => {
Expand All @@ -126,6 +176,7 @@ const createTypePages = (type, results, createPage) => {
currentPage: i + 1,
type: `/${type}/`,
numPages: numPages,
pinned: pinnedId,
},
})
})
Expand Down
32 changes: 6 additions & 26 deletions src/components/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import Footer from "./footer"
import Header from "./header"
import layoutStyles from "./layout.module.scss"
import PinnedCard from "./pinnedCard"
import AllPinned from "./pinnedNode/allPinned"
import EngPinned from "./pinnedNode/engineeringPinned"
import GrowthPinned from "./pinnedNode/growthPinned"
import IdentityPinned from "./pinnedNode/identityPinned"

const Layout = ({ postPage, children, pinned, pinnedData, pathname, type }) => {
return (
Expand Down Expand Up @@ -40,17 +36,13 @@ const Layout = ({ postPage, children, pinned, pinnedData, pathname, type }) => {
pathname={pathname}
type={type}
/>
<div className={layoutStyles.pinnedwrap}>
<div className={layoutStyles.blogContentPinned}>
{pinned ? (
pinnedData.length ? (
<PinnedCard node={pinnedData[0].node} />
) : (
getFirstNode(type)
)
) : null}
{pinned ? (
<div className={layoutStyles.pinnedwrap}>
<div className={layoutStyles.blogContentPinned}>
<PinnedCard node={pinnedData} />
</div>
</div>
</div>
) : null}
<div className={layoutStyles.blogContent}>
<div className={layoutStyles.content}>{children}</div>
</div>
Expand All @@ -67,16 +59,4 @@ const Layout = ({ postPage, children, pinned, pinnedData, pathname, type }) => {
)
}

const getFirstNode = type => {
if (type === "engineering") {
return <EngPinned />
} else if (type === "growth") {
return <GrowthPinned />
} else if (type === "identity") {
return <IdentityPinned />
} else {
return <AllPinned />
}
}

export default Layout
51 changes: 0 additions & 51 deletions src/components/pinnedNode/allPinned.js

This file was deleted.

52 changes: 0 additions & 52 deletions src/components/pinnedNode/engineeringPinned.js

This file was deleted.

52 changes: 0 additions & 52 deletions src/components/pinnedNode/growthPinned.js

This file was deleted.

52 changes: 0 additions & 52 deletions src/components/pinnedNode/identityPinned.js

This file was deleted.

Loading

0 comments on commit 3131c6b

Please sign in to comment.