Merge pull request #229 from acid-info/detailings-amir

Detailings amir
This commit is contained in:
Hossein Mehrabi 2024-01-25 16:40:00 +03:30 committed by GitHub
commit 5301a81728
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 36 additions and 11 deletions

2
.gitignore vendored
View File

@ -40,3 +40,5 @@ public/rss.xml
public/atom*.xml
public/images/placeholders/*
!public/images/placeholders/.gitkeep
public/rss/*.xml

View File

@ -18,6 +18,7 @@ type Metadata = {
date?: string | null
contentType?: LPE.PostType
noIndex?: boolean
rssFileName?: string
}
const SITE_URL = getWebsiteUrl()
@ -36,6 +37,7 @@ export default function SEO({
date,
contentType,
noIndex = false,
rssFileName,
}: Metadata) {
const title =
_title && _title.length
@ -75,12 +77,7 @@ export default function SEO({
<link
rel="alternate"
type="application/rss+xml"
href={`${getWebsiteUrl()}/rss.xml`}
/>
<link
rel="alternate"
type="application/atom+xml"
href={`${getWebsiteUrl()}/atom.xml`}
href={`${getWebsiteUrl()}/rss/${rssFileName ?? 'main.rss'}`}
/>
{noIndex && (
<>

View File

@ -1,3 +1,4 @@
import { LPERssFeed } from '@/services/rss.service'
import { CustomNextPage, GetStaticProps } from 'next'
import SEO from '../components/SEO/SEO'
import { HomePage, HomePageProps } from '../containers/HomePage'
@ -9,7 +10,7 @@ type PageProps = Pick<HomePageProps, 'data'>
const Page: CustomNextPage<PageProps> = (props) => {
return (
<>
<SEO />
<SEO rssFileName={'main.rss'} />
<HomePage data={props.data} />
</>
)
@ -42,6 +43,11 @@ export const getStaticProps: GetStaticProps<PageProps> = async () => {
const { data: tags = [] } = await strapiApi.getTopics()
const rss = new LPERssFeed('main')
await rss.init()
latest.data.forEach((post) => rss.addPost(post))
await rss.save()
return {
props: {
data: {

View File

@ -1,5 +1,6 @@
import { SEO } from '@/components/SEO'
import PodcastShowContainer from '@/containers/PodcastShowContainer'
import { LPERssFeed } from '@/services/rss.service'
import { GetStaticPropsContext } from 'next'
import { useRouter } from 'next/router'
import { ReactNode } from 'react'
@ -37,6 +38,7 @@ const PodcastShowPage = ({
imageUrl={undefined}
pagePath={getPostLink('podcast', { showSlug: showSlug as string })}
tags={[]}
rssFileName={`${showSlug}.xml`}
/>
<PodcastShowContainer
show={show}
@ -96,6 +98,20 @@ export const getStaticProps = async ({ params }: GetStaticPropsContext) => {
showSlug: showSlug as string,
})
const rss = new LPERssFeed(showSlug as string, {
title: shows[0].title,
description: shows[0].descriptionText,
image: shows[0].logo.url,
language: 'en',
id: shows[0].id ?? (showSlug as string),
copyright: `All rights reserved ${new Date().getFullYear()}, ${
shows[0].title
}`,
})
await rss.init()
latestEpisodes.data.forEach((post: LPE.Post.Document) => rss.addPost(post))
await rss.save()
return {
props: {
show: shows[0],

View File

@ -113,7 +113,7 @@ export class LPERssFeed {
category: [
...(post.type === 'article'
? [articleCategory]
: [showCategories[post.show!.id]]),
: [showCategories[post.showId as string]]),
...post.tags.map(
(tag) =>
({

View File

@ -100,10 +100,10 @@ export const transformStrapiHtmlContent = async ({
const tagName = node.tagName.toLowerCase()
const isFigure = tagName === 'figure'
const isMedia = isFigure && !!node.querySelector('oembed')
const isImage = isFigure && !isMedia && !!node.querySelector('img')
const isImage = !!node.querySelector('img')
const empty = node.text.length === 0
if (!isFigure && empty) continue
if (!isFigure && !isImage && empty) continue
blockIndex++
@ -116,7 +116,8 @@ export const transformStrapiHtmlContent = async ({
const caption = text
const alt = image.getAttribute('alt') || ''
const url = image.getAttribute('src') || ''
let url = image.getAttribute('src') || ''
url = url.slice(url.indexOf('/uploads/'))
const width = parseInt(image.getAttribute('width') || '0', 10)
const height = parseInt(image.getAttribute('height') || '0', 10)
@ -130,6 +131,9 @@ export const transformStrapiHtmlContent = async ({
alt: alt || caption,
labels: [],
order: blockIndex,
placeholder: isVercel()
? getStrapiImageUrlBySize('thumbnail', url)
: await placeholderService.pixelate(url),
url: url.startsWith('/') ? transformStrapiImageUrl(url) : url,
footnotes,
})