Skip to content

Commit ac92526

Browse files
committed
categorized post endpoint updated
1 parent 3289ea0 commit ac92526

File tree

6 files changed

+37
-31
lines changed

6 files changed

+37
-31
lines changed

gatsby-node.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ exports.createPages = ({ actions }) => {
2424
return new Promise(async (resolve, reject) => {
2525
try {
2626
const { data: basic } = await axios(
27-
`http://with.zonayed.me/api/${BASIC}/index.json`
27+
`https://with.zonayed.me/api/${BASIC}/index.json`
2828
)
2929
const { data: advance } = await axios(
30-
`http://with.zonayed.me/api/${ADVANCE}/index.json`
30+
`https://with.zonayed.me/api/${ADVANCE}/index.json`
3131
)
3232
const { data: es6 } = await axios(
33-
`http://with.zonayed.me/api/${ES6}/index.json`
33+
`https://with.zonayed.me/api/${ES6}/index.json`
3434
)
3535
const { data: dom } = await axios(
36-
`http://with.zonayed.me/api/${DOM}/index.json`
36+
`https://with.zonayed.me/api/${DOM}/index.json`
3737
)
3838
const { data: daily } = await axios(
39-
`http://with.zonayed.me/api/${DAILY}/index.json`
39+
`https://with.zonayed.me/api/${DAILY}/index.json`
4040
)
4141
const { data: algods } = await axios(
42-
`http://with.zonayed.me/api/${ALGODS}/index.json`
42+
`https://with.zonayed.me/api/${ALGODS}/index.json`
4343
)
4444
const { data: soft } = await axios(
45-
`http://with.zonayed.me/api/${SOFT}/index.json`
45+
`https://with.zonayed.me/api/${SOFT}/index.json`
4646
)
4747
const data = {
4848
basic,
@@ -53,7 +53,6 @@ exports.createPages = ({ actions }) => {
5353
algods,
5454
soft,
5555
}
56-
console.log(data)
5756
const dataTitle = {
5857
basic: basic.map(item => ({
5958
id: item.contentDir,
@@ -101,22 +100,26 @@ exports.createPages = ({ actions }) => {
101100
component: homePageTemplate,
102101
})
103102
Object.keys(res.dataTitle).map(topic => {
103+
console.log(topic)
104104
createPage({
105105
path: `/${topic}`,
106106
context: {
107107
data: res.dataTitle[topic],
108108
},
109109
component: topicPageTemplate,
110110
})
111-
res.dataTitle[topic].map(async item => {
112-
createPage({
113-
path: `/${topic}/${item.id}`,
114-
context: {
115-
id: item.contentDir,
116-
},
117-
component: postPageTemplate,
118-
})
119-
})
111+
// res.data[topic].map((item, index) => {
112+
// const post = `post-${index}`
113+
// createPage({
114+
// path: `/${topic}/${post}`,
115+
// context: {
116+
// id: index,
117+
// data: item,
118+
// allData: data,
119+
// },
120+
// component: postPageTemplate,
121+
// })
122+
// })
120123
})
121124
})
122125
.catch(err => {

src/components/card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import './card.css'
1111
const Card = ({ id, title, action, topic }) => {
1212
return (
1313
<li className={`card ${action ? action : ''}`}>
14-
<Link to={`/${topic}/${id}`}>
14+
<Link to={`/${topic}/post-${id}`}>
1515
<h4 dangerouslySetInnerHTML={{ __html: sliceCat(title) }} />
1616
</Link>
1717
{action && (

src/components/category.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Card from './card'
66

77
import './category.css'
88

9-
const Category = ({ topic, data }) => {
9+
const Category = ({ id, topic, data }) => {
1010
return (
1111
<div key={topic} className="topic">
1212
<div className="title">
@@ -21,7 +21,7 @@ const Category = ({ topic, data }) => {
2121
</div>
2222
<ul>
2323
{data.map(({ id, title }, index) => (
24-
<Card key={id} id={id} title={title} index={index} topic={topic} />
24+
<Card key={id} id={index} title={title} index={index} topic={topic} />
2525
))}
2626
</ul>
2727
</div>

src/components/post.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const Post = ({ allData, path, title, content }) => {
2626
<Link
2727
to={`/${prevPost.category}/${prevPost.id}`}
2828
dangerouslySetInnerHTML={{
29-
__html: sliceCat(prevPost.title.rendered),
29+
__html: sliceCat(prevPost.title),
3030
}}
3131
/>
3232
</p>
@@ -39,7 +39,7 @@ const Post = ({ allData, path, title, content }) => {
3939
<Link
4040
to={`/${nextPost.category}/${nextPost.id}`}
4141
dangerouslySetInnerHTML={{
42-
__html: sliceCat(nextPost.title.rendered),
42+
__html: sliceCat(nextPost.title),
4343
}}
4444
/>
4545
</p>

src/templates/PostPage.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,32 @@ import { handleLastRead, logInstruction } from '../utils'
88

99
import './postpage.css'
1010

11-
const PostPage = ({ path, pageContext: { data, allData } }) => {
11+
const PostPage = ({ path, pageContext: { id, data, allData } }) => {
12+
window.log = allData
1213
useEffect(() => {
1314
logInstruction()
1415
handleLastRead({
15-
id: data.id,
16-
title: data.title.rendered,
16+
id,
17+
title: data.title,
1718
topic: path.split('/')[1],
1819
})
1920
})
2021
return (
2122
<Layout>
22-
<SEO
23-
title={data.title.rendered}
24-
description={String(data.excerpt.rendered).replace(/<[^>]*>/g, '')}
23+
<p>PostPage</p>
24+
{/* <SEO
25+
title={data.title}
26+
description={'একটা শর্টে লেখার অংশবিশেষ'}
2527
/>
2628
<div className="post-area">
2729
<Post
2830
allData={allData}
2931
path={path}
30-
title={data.title.rendered}
31-
content={data.content.rendered}
32+
title={data.title}
33+
content={data.content}
3234
/>
3335
<Catalog path={path} topics={allData} />
34-
</div>
36+
</div> */}
3537
</Layout>
3638
)
3739
}

src/templates/TopicPage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { topicTranslation } from '../utils'
77
import './topicpage.css'
88

99
const TopicPage = ({ path, pageContext: { data } }) => {
10+
console.log(data)
1011
const topic = path.replace('/', '')
1112
return (
1213
<Layout>

0 commit comments

Comments
 (0)