События и первый конкурс #6
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;
|
||||
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue