Moved to using Project instead of Tags
for StoryPager and Feed Generator
This commit is contained in:
parent
a432fa74aa
commit
71fd840606
4 changed files with 20 additions and 9 deletions
13
data/external/cms.js
vendored
13
data/external/cms.js
vendored
|
|
@ -17,16 +17,11 @@ export const getAllPosts = async (filter, page, limit) => {
|
|||
var filters = {}
|
||||
|
||||
if (filter) {
|
||||
const tagList = []
|
||||
filter.data.forEach(tag => {
|
||||
console.log(tag)
|
||||
tagList.push(tag.attributes.Slug)
|
||||
})
|
||||
|
||||
filters = {
|
||||
tags: {
|
||||
project: {
|
||||
Slug: {
|
||||
$in: tagList
|
||||
$in: filter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -114,4 +109,8 @@ export const getProjectDetails = async (projectId) => {
|
|||
})
|
||||
|
||||
return await res.json()
|
||||
}
|
||||
|
||||
export const getPodcastEpisode = async (episodeId) => {
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ export const generateRssFeed = async (filter) => {
|
|||
|
||||
const project = await getProjectDetails(filter);
|
||||
|
||||
const posts = typeof filter === "undefined" ? await getAllPosts() : await getAllPosts(project.data[0].attributes.tags);
|
||||
const posts = typeof filter === "undefined" ? await getAllPosts() : await getAllPosts(project.data[0].attributes.Slug);
|
||||
|
||||
const siteURL = config.siteURL;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,23 @@ export async function getStaticProps({params}) {
|
|||
|
||||
const article_obj = await getSinglePost(slug)
|
||||
|
||||
var filters = {};
|
||||
|
||||
if (article_obj.project.data != null) {
|
||||
filters = (
|
||||
{
|
||||
project: {
|
||||
Slug: article_obj.project.data.attributes.Slug
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const qs = require('qs')
|
||||
const query = qs.stringify({
|
||||
pagination: {
|
||||
limit: 5
|
||||
},
|
||||
filters,
|
||||
sort: ['publishedAt:desc']
|
||||
}, {
|
||||
encodeValuesOnly: true,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export async function getServerSideProps(context) {
|
|||
|
||||
const rssFeed = config.siteURL+"/feed/"+project.data[0].attributes.Slug+"-feed.xml"
|
||||
|
||||
const articles = await getAllPosts(project.data[0].attributes.tags, page, 5)
|
||||
const articles = await getAllPosts([project.data[0].attributes.Slug], page, 5)
|
||||
|
||||
const secres = await fetch(serverRuntimeConfig.base_path + `/api/sections`)
|
||||
const secdata = await secres.json()
|
||||
|
|
|
|||
Loading…
Reference in a new issue