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 = {}
|
var filters = {}
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
const tagList = []
|
|
||||||
filter.data.forEach(tag => {
|
|
||||||
console.log(tag)
|
|
||||||
tagList.push(tag.attributes.Slug)
|
|
||||||
})
|
|
||||||
|
|
||||||
filters = {
|
filters = {
|
||||||
tags: {
|
project: {
|
||||||
Slug: {
|
Slug: {
|
||||||
$in: tagList
|
$in: filter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -115,3 +110,7 @@ export const getProjectDetails = async (projectId) => {
|
||||||
|
|
||||||
return await res.json()
|
return await res.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getPodcastEpisode = async (episodeId) => {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ export const generateRssFeed = async (filter) => {
|
||||||
|
|
||||||
const project = await getProjectDetails(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;
|
const siteURL = config.siteURL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,23 @@ export async function getStaticProps({params}) {
|
||||||
|
|
||||||
const article_obj = await getSinglePost(slug)
|
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 qs = require('qs')
|
||||||
const query = qs.stringify({
|
const query = qs.stringify({
|
||||||
pagination: {
|
pagination: {
|
||||||
limit: 5
|
limit: 5
|
||||||
},
|
},
|
||||||
|
filters,
|
||||||
sort: ['publishedAt:desc']
|
sort: ['publishedAt:desc']
|
||||||
}, {
|
}, {
|
||||||
encodeValuesOnly: true,
|
encodeValuesOnly: true,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export async function getServerSideProps(context) {
|
||||||
|
|
||||||
const rssFeed = config.siteURL+"/feed/"+project.data[0].attributes.Slug+"-feed.xml"
|
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 secres = await fetch(serverRuntimeConfig.base_path + `/api/sections`)
|
||||||
const secdata = await secres.json()
|
const secdata = await secres.json()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue