В RSS-ленте выводятся даты начала и окончания события
This commit is contained in:
parent
2f255c96c1
commit
528e19a012
1 changed files with 10 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { fetchPostsSorted, resolveBlogPath } from "$src/lib/util/Blogs";
|
import { EventStatus, fetchPostsSorted, postEventStatus, resolveBlogPath } from "$lib/util/Blogs";
|
||||||
|
|
||||||
export const prerender = true;
|
export const prerender = true;
|
||||||
|
|
||||||
|
|
@ -41,6 +41,14 @@ function makeAuthors(post: App.BlogPost): string {
|
||||||
return `\n<author>${authorsString}</author>`;
|
return `\n<author>${authorsString}</author>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeEventDescription(post: App.BlogPost): string {
|
||||||
|
if (postEventStatus(post) === EventStatus.NotEvent)
|
||||||
|
return '';
|
||||||
|
|
||||||
|
const dateToUtcString = (s: string) => new Date(s).toUTCString();
|
||||||
|
return `<br><br>Событие проводится с ${dateToUtcString(post.dateEventFrom!)} по ${dateToUtcString(post.dateEventFrom!)}.`;
|
||||||
|
}
|
||||||
|
|
||||||
export async function GET({ setHeaders }) {
|
export async function GET({ setHeaders }) {
|
||||||
setHeaders({
|
setHeaders({
|
||||||
'Cache-Control': 'max-age=0, s-maxage=3600',
|
'Cache-Control': 'max-age=0, s-maxage=3600',
|
||||||
|
|
@ -57,7 +65,7 @@ export async function GET({ setHeaders }) {
|
||||||
<ttl>1800</ttl>
|
<ttl>1800</ttl>
|
||||||
${posts.map((post) => `<item>
|
${posts.map((post) => `<item>
|
||||||
<title>${escapeXml(post.title)}</title>
|
<title>${escapeXml(post.title)}</title>
|
||||||
<description><![CDATA[${escapeXml(post.description)}${makeThumbnail(post)}]]></description>${makeAuthors(post)}
|
<description><![CDATA[${escapeXml(post.description)}${makeEventDescription(post)}${makeThumbnail(post)}]]></description>${makeAuthors(post)}
|
||||||
<guid isPermaLink="true">https://teasanctuary.ru/blog/${post.slug}</guid>
|
<guid isPermaLink="true">https://teasanctuary.ru/blog/${post.slug}</guid>
|
||||||
<link>https://teasanctuary.ru/blog/${post.slug}</link>
|
<link>https://teasanctuary.ru/blog/${post.slug}</link>
|
||||||
<pubDate>${(new Date(post.date!)).toUTCString()}</pubDate>
|
<pubDate>${(new Date(post.date!)).toUTCString()}</pubDate>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue