Fixed error in feed generation

This commit is contained in:
James Purser 2022-06-18 21:36:21 +10:00
parent 7e5a8f94b1
commit db783414c9
2 changed files with 12 additions and 5 deletions

View file

@ -7,7 +7,7 @@ export const generateRssFeed = async (filter) => {
const project = await getProjectDetails(filter); const project = await getProjectDetails(filter);
const posts = await getAllPosts(project.data[0].attributes.tags); const posts = typeof filter === "undefined" ? await getAllPosts() : await getAllPosts(project.data[0].attributes.tags);
const siteURL = config.siteURL; const siteURL = config.siteURL;

View file

@ -1,8 +1,10 @@
import "../components/main" import "../components/main"
import getConfig from 'next/config' import getConfig from 'next/config'
import config from "../data/internal/config"
import Layout from "../components/main" import Layout from "../components/main"
import StoryPager from "../components/storypager" import StoryPager from "../components/storypager"
import { getAllPosts, getProjectDetails } from "../data/external/cms"; import { getAllPosts, getProjectDetails } from "../data/external/cms";
import Head from 'next/head'
//import { popStoryPager } from "../data/external/cms" //import { popStoryPager } from "../data/external/cms"
export async function getServerSideProps(context) { export async function getServerSideProps(context) {
@ -16,6 +18,8 @@ export async function getServerSideProps(context) {
const project = await getProjectDetails('tech-and-disability') const project = await getProjectDetails('tech-and-disability')
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.tags, page, 5)
const secres = await fetch(serverRuntimeConfig.base_path + `/api/sections`) const secres = await fetch(serverRuntimeConfig.base_path + `/api/sections`)
@ -24,16 +28,19 @@ export async function getServerSideProps(context) {
const pagedata = {'title': 'Tech and Disability'} const pagedata = {'title': 'Tech and Disability'}
return { return {
props: { articles, sections : secdata, pagedata, project }, // will be passed to the page component as props props: { articles, sections : secdata, pagedata, project, rssFeed}, // will be passed to the page component as props
} }
} }
function Project({ articles, sections, pagedata, project }) { function Project({ articles, sections, pagedata, project, rssFeed }) {
return <Layout sections={sections} pagedata={pagedata}> return <div><Head>
<link rel="alternate" type="application/rss+xml" title="Example Feed" href={rssFeed} />
</Head>
<Layout sections={sections} pagedata={pagedata}>
<h1>{project.data[0].attributes.Title}</h1> <h1>{project.data[0].attributes.Title}</h1>
<div dangerouslySetInnerHTML={{ __html: project.data[0].attributes.Description }}></div> <div dangerouslySetInnerHTML={{ __html: project.data[0].attributes.Description }}></div>
<StoryPager storydata={articles} /> <StoryPager storydata={articles} />
</Layout> </Layout></div>
} }
export default Project export default Project