События и первый конкурс #6

Merged
rndtrash merged 19 commits from feature/events into master 2025-11-26 11:46:26 +03:00
Showing only changes of commit 528e19a012 - Show all commits

View file

@ -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;
@ -41,6 +41,14 @@ function makeAuthors(post: App.BlogPost): string {
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 }) {
setHeaders({
'Cache-Control': 'max-age=0, s-maxage=3600',
@ -57,7 +65,7 @@ export async function GET({ setHeaders }) {
<ttl>1800</ttl>
${posts.map((post) => `<item>
<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>
<link>https://teasanctuary.ru/blog/${post.slug}</link>
<pubDate>${(new Date(post.date!)).toUTCString()}</pubDate>