Full support for Podcast Series and Episodes
This commit is contained in:
parent
ad85231444
commit
becd7c7cbf
6 changed files with 52 additions and 34 deletions
33
data/external/cms.js
vendored
33
data/external/cms.js
vendored
|
|
@ -148,7 +148,7 @@ export const getPodcastSeries = async (podcastId) => {
|
||||||
}, {
|
}, {
|
||||||
encodeValuesOnly: true,
|
encodeValuesOnly: true,
|
||||||
})
|
})
|
||||||
const url = serverRuntimeConfig.base_path + `/api/podcast-serie?${query}`;
|
const url = serverRuntimeConfig.base_path + `podcast-series?${query}`;
|
||||||
const showres = await fetch(url, {
|
const showres = await fetch(url, {
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
'Authorization': serverRuntimeConfig.strapi_token,
|
'Authorization': serverRuntimeConfig.strapi_token,
|
||||||
|
|
@ -186,4 +186,35 @@ export const getPodcastSeriesEpisodes = async (podcastId, limit, page) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
return await epres.json();
|
return await epres.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getLatestPodcastEpisode = async () => {
|
||||||
|
const { serverRuntimeConfig} = getConfig()
|
||||||
|
const qs = require('qs')
|
||||||
|
var query = qs.stringify({
|
||||||
|
sort: ['publishedAt:desc'],
|
||||||
|
pagination: {
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
},
|
||||||
|
populate: '*'
|
||||||
|
})
|
||||||
|
|
||||||
|
const epres = await fetch(serverRuntimeConfig.base_path + `podcast-episodes?${query}`, {
|
||||||
|
headers: new Headers({
|
||||||
|
'Authorization': serverRuntimeConfig.strapi_token,
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const episode = await epres.json()
|
||||||
|
|
||||||
|
const seriesres = await getPodcastSeries(episode.data[0].attributes.podcast_sery.data.attributes.Slug)
|
||||||
|
|
||||||
|
const res = {
|
||||||
|
...episode,
|
||||||
|
...seriesres.data[0].attributes
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
@ -68,11 +68,6 @@ export const generateRssFeed = async (filter) => {
|
||||||
|
|
||||||
const url = `${siteURL}/news/${post.attributes.Slug}`;
|
const url = `${siteURL}/news/${post.attributes.Slug}`;
|
||||||
|
|
||||||
console.log(htmlFindReplaceElementAttrs.find(
|
|
||||||
post.attributes.Body,
|
|
||||||
{tag: "img", attr: "src"}
|
|
||||||
))
|
|
||||||
|
|
||||||
const body = htmlFindReplaceElementAttrs.replace(
|
const body = htmlFindReplaceElementAttrs.replace(
|
||||||
post.attributes.Body,
|
post.attributes.Body,
|
||||||
item => item.parsedUrl,
|
item => item.parsedUrl,
|
||||||
|
|
@ -120,8 +115,6 @@ export const generateRssFeed = async (filter) => {
|
||||||
export const generatePodcastFeeds = async () => {
|
export const generatePodcastFeeds = async () => {
|
||||||
const podcastSeries = await getAllPodcastSeries()
|
const podcastSeries = await getAllPodcastSeries()
|
||||||
const siteURL = config.siteURL;
|
const siteURL = config.siteURL;
|
||||||
|
|
||||||
console.log(config)
|
|
||||||
|
|
||||||
const author = {
|
const author = {
|
||||||
|
|
||||||
|
|
@ -143,9 +136,9 @@ export const generatePodcastFeeds = async () => {
|
||||||
|
|
||||||
description: series.attributes.Description,
|
description: series.attributes.Description,
|
||||||
|
|
||||||
id: siteURL,
|
id: siteURL + "/podcasts/shows/" + series.attributes.Slug,
|
||||||
|
|
||||||
link: siteURL,
|
link: siteURL + "/podcasts/shows/" + series.attributes.Slug,
|
||||||
|
|
||||||
image: `${siteURL}/public/images/logo.svg`,
|
image: `${siteURL}/public/images/logo.svg`,
|
||||||
|
|
||||||
|
|
@ -171,7 +164,7 @@ export const generatePodcastFeeds = async () => {
|
||||||
|
|
||||||
episodes.forEach((episode) => {
|
episodes.forEach((episode) => {
|
||||||
|
|
||||||
const url = `${siteURL}/shows/${series.attributes.Slug}/${episode.attributes.Slug}`;
|
const url = `${siteURL}/podcasts/shows/${series.attributes.Slug}/${episode.attributes.Slug}`;
|
||||||
|
|
||||||
const media_url = `${siteURL}${episode.attributes.Audio_MP3.data.attributes.url}`
|
const media_url = `${siteURL}${episode.attributes.Audio_MP3.data.attributes.url}`
|
||||||
|
|
||||||
|
|
@ -205,8 +198,6 @@ export const generatePodcastFeeds = async () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(feed.rss2())
|
|
||||||
|
|
||||||
fs.writeFileSync(`./public/feed/${series.attributes.Slug}.xml`, feed.rss2());
|
fs.writeFileSync(`./public/feed/${series.attributes.Slug}.xml`, feed.rss2());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ export const generateSitemap = async () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map((staticPagePath) => {
|
.map((staticPagePath) => {
|
||||||
console.log(staticPagePath)
|
|
||||||
return `${config.siteURL}/${path.parse(staticPagePath.name).name}`;
|
return `${config.siteURL}/${path.parse(staticPagePath.name).name}`;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -31,8 +30,6 @@ export const generateSitemap = async () => {
|
||||||
const postList = []
|
const postList = []
|
||||||
postData.data.forEach(post => postList.push({slug: post.attributes.Slug, updatedAt: post.attributes.updatedAt}))
|
postData.data.forEach(post => postList.push({slug: post.attributes.Slug, updatedAt: post.attributes.updatedAt}))
|
||||||
|
|
||||||
console.log(postList)
|
|
||||||
|
|
||||||
const formatted = sitemap => prettier.format(sitemap, { parser: "html" });
|
const formatted = sitemap => prettier.format(sitemap, { parser: "html" });
|
||||||
|
|
||||||
const pageListMap = staticPaths.map(page => {
|
const pageListMap = staticPaths.map(page => {
|
||||||
|
|
@ -62,8 +59,6 @@ xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitem
|
||||||
>${pageListMap}${postListSiteMap}
|
>${pageListMap}${postListSiteMap}
|
||||||
</urlset>
|
</urlset>
|
||||||
`
|
`
|
||||||
|
|
||||||
console.log(generatedSitemap)
|
|
||||||
const formattedSitemap = [formatted(generatedSitemap)];
|
const formattedSitemap = [formatted(generatedSitemap)];
|
||||||
|
|
||||||
fs.writeFileSync("public/sitemap.xml", generatedSitemap, "utf8")
|
fs.writeFileSync("public/sitemap.xml", generatedSitemap, "utf8")
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import Image from 'next/image';
|
||||||
import { FEEDS, getFeed } from "../lib/rss"
|
import { FEEDS, getFeed } from "../lib/rss"
|
||||||
import { generatePodcastFeeds, generateRssFeed } from "../data/internal/feed-generator"
|
import { generatePodcastFeeds, generateRssFeed } from "../data/internal/feed-generator"
|
||||||
import { generateSitemap } from "../data/internal/sitemap-generator"
|
import { generateSitemap } from "../data/internal/sitemap-generator"
|
||||||
|
import { getLatestPodcastEpisode } from "../data/external/cms"
|
||||||
|
|
||||||
export async function getStaticProps(context) {
|
export async function getStaticProps(context) {
|
||||||
generateRssFeed()
|
generateRssFeed()
|
||||||
|
|
@ -14,7 +15,6 @@ export async function getStaticProps(context) {
|
||||||
generatePodcastFeeds()
|
generatePodcastFeeds()
|
||||||
generateSitemap()
|
generateSitemap()
|
||||||
const { serverRuntimeConfig, publicRuntimeConfig, strapiConfig } = getConfig()
|
const { serverRuntimeConfig, publicRuntimeConfig, strapiConfig } = getConfig()
|
||||||
console.log(serverRuntimeConfig.strapi_token)
|
|
||||||
|
|
||||||
const qs = require('qs')
|
const qs = require('qs')
|
||||||
const query = qs.stringify({
|
const query = qs.stringify({
|
||||||
|
|
@ -26,7 +26,7 @@ export async function getStaticProps(context) {
|
||||||
}, {
|
}, {
|
||||||
encodeValuesOnly: true,
|
encodeValuesOnly: true,
|
||||||
})
|
})
|
||||||
console.log(query)
|
|
||||||
const res = await fetch(serverRuntimeConfig.base_path +`articles?${query}`, {
|
const res = await fetch(serverRuntimeConfig.base_path +`articles?${query}`, {
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
'Authorization': serverRuntimeConfig.strapi_token,
|
'Authorization': serverRuntimeConfig.strapi_token,
|
||||||
|
|
@ -37,9 +37,8 @@ export async function getStaticProps(context) {
|
||||||
|
|
||||||
const article = artdata.data[0].attributes
|
const article = artdata.data[0].attributes
|
||||||
|
|
||||||
console.log(article)
|
const epdata = await getLatestPodcastEpisode()
|
||||||
// const epres = await fetch(serverRuntimeConfig.base_path + '/api/podcasts/episodes/latest/0/1')
|
console.log(epdata.Logo.data.attributes.height)
|
||||||
// const epdata = await epres.json()
|
|
||||||
|
|
||||||
const flickr = await fetch('https://www.flickr.com/services/feeds/photos_public.gne?id=25875680@N05&lang=en-us&format=json&nojsoncallback=1')
|
const flickr = await fetch('https://www.flickr.com/services/feeds/photos_public.gne?id=25875680@N05&lang=en-us&format=json&nojsoncallback=1')
|
||||||
const flickrdata = await flickr.json()
|
const flickrdata = await flickr.json()
|
||||||
|
|
@ -52,7 +51,7 @@ export async function getStaticProps(context) {
|
||||||
// const tadfirstitem = tadfullfeed.items[0]
|
// const tadfirstitem = tadfullfeed.items[0]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: { article, pagedata, config: serverRuntimeConfig, firstimage},
|
props: { article, pagedata, config: serverRuntimeConfig, firstimage, episodedata: epdata},
|
||||||
revalidate: 60 // will be passed to the page component as props
|
revalidate: 60 // will be passed to the page component as props
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,30 +85,29 @@ function HomePage (props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* {props.episodedata.map((episode) => (
|
{props.episodedata.data.map((episode) => (
|
||||||
<div className="col-sm-4">
|
<div className="col-sm-4">
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-img-top">
|
<div className="card-img-top">
|
||||||
<Image
|
<Image
|
||||||
src={props.config.base_path + "/" + episode.logo.src}
|
src={props.config.base_path + "/" + props.episodedata.Logo.data.attributes.url}
|
||||||
alt={episode.show}
|
alt={episode.show}
|
||||||
layout="fixed"
|
layout="fixed"
|
||||||
height={episode.logo.height}
|
height={props.episodedata.Logo.data.attributes.height}
|
||||||
width={episode.logo.width}
|
width={props.episodedata.Logo.data.attributes.width}
|
||||||
srcSet={episode.logo.srcset}
|
|
||||||
className="card-img-top"
|
className="card-img-top"
|
||||||
></Image>
|
></Image>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-title">
|
<div className="card-title">
|
||||||
<h3>Latest Podcast</h3>
|
<h3>Latest Podcast</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
<Link href={"/podcasts/shows/" + episode.show_slug + "/" + episode.episode_slug}>{episode.title}</Link>
|
<Link href={"/podcasts/shows/" + props.episodedata.data[0].attributes.podcast_sery.Slug + "/" + props.episodedata.data[0].attributes.Slug}>{props.episodedata.data[0].attributes.Title}</Link>
|
||||||
<div dangerouslySetInnerHTML={{ __html: episode.episode_lead}}></div>
|
<div dangerouslySetInnerHTML={{ __html: episode.episode_lead}}></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))} */}
|
))}
|
||||||
<div className="col-sm-4">
|
<div className="col-sm-4">
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-img-top">
|
<div className="card-img-top">
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ export async function getServerSideProps(context) {
|
||||||
|
|
||||||
const episode = await getPodcastEpisode(slug)
|
const episode = await getPodcastEpisode(slug)
|
||||||
|
|
||||||
const sepisodes = await getPodcastSeriesEpisodes(slug[0], 5, 0)
|
const sepisodes = await getPodcastSeriesEpisodes(episode.data[0].attributes.podcast_sery.data.attributes.Slug, 5, 0)
|
||||||
|
|
||||||
|
console.log(sepisodes)
|
||||||
|
|
||||||
const audiodata = {
|
const audiodata = {
|
||||||
audio_path: serverRuntimeConfig.audio_path,
|
audio_path: serverRuntimeConfig.audio_path,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ export async function getServerSideProps(context) {
|
||||||
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
||||||
const slug = context.params.podcast
|
const slug = context.params.podcast
|
||||||
const showdata = await getPodcastSeries(slug)
|
const showdata = await getPodcastSeries(slug)
|
||||||
|
|
||||||
|
console.log(showdata.data)
|
||||||
|
|
||||||
if(context.query.page == null || context.query.page == '0') {
|
if(context.query.page == null || context.query.page == '0') {
|
||||||
var page = 0;
|
var page = 0;
|
||||||
|
|
@ -16,7 +18,6 @@ export async function getServerSideProps(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const epdata = await getPodcastSeriesEpisodes(slug, 5, page)
|
const epdata = await getPodcastSeriesEpisodes(slug, 5, page)
|
||||||
console.log(epdata.data)
|
|
||||||
|
|
||||||
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