Moved to using Project instead of Tags

for StoryPager and Feed Generator
This commit is contained in:
James Purser 2022-06-20 15:22:16 +10:00
parent a432fa74aa
commit 71fd840606
4 changed files with 20 additions and 9 deletions

13
data/external/cms.js vendored
View file

@ -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
}
}
}
@ -115,3 +110,7 @@ export const getProjectDetails = async (projectId) => {
return await res.json()
}
export const getPodcastEpisode = async (episodeId) => {
}

View file

@ -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;

View file

@ -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,

View file

@ -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()