diff --git a/data/external/cms.js b/data/external/cms.js index bacf189..30c5d2f 100755 --- a/data/external/cms.js +++ b/data/external/cms.js @@ -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) => { + } \ No newline at end of file diff --git a/data/internal/feed-generator.js b/data/internal/feed-generator.js index 6ac21f0..92f4b81 100755 --- a/data/internal/feed-generator.js +++ b/data/internal/feed-generator.js @@ -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; diff --git a/pages/news/[slug].js b/pages/news/[slug].js index 589ac3c..2022180 100755 --- a/pages/news/[slug].js +++ b/pages/news/[slug].js @@ -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, diff --git a/pages/tech-and-disability.js b/pages/tech-and-disability.js index eed6b4a..be1239d 100755 --- a/pages/tech-and-disability.js +++ b/pages/tech-and-disability.js @@ -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()