Блоги #1

Merged
rndtrash merged 64 commits from feature-blogs into master 2025-10-22 08:44:56 +03:00
Showing only changes of commit dcbd8a5980 - Show all commits

View file

@ -21,6 +21,26 @@ function makeThumbnail(post: App.BlogPost): string {
return `<br><br><img src="https://teasanctuary.ru${resolveBlogPath(post.slug, post.thumbnail)}"${alt}>`;
}
function makeAuthors(post: App.BlogPost): string {
const authors =
(post.authors == null
? []
: typeof post.authors === 'string'
? [post.authors]
: post.authors)
.map(a => escapeXml(a));
if (authors.length === 0) return '';
let authorsString = authors[0];
if (authors.length > 1) {
const lastAuthor = authors.pop();
authorsString = `${authors.join(', ')} и ${lastAuthor}`;
}
return `\n<author>${authorsString}</author>`;
}
export async function GET({ setHeaders }) {
setHeaders({
'Cache-Control': 'max-age=0, s-maxage=3600',
@ -36,7 +56,7 @@ export async function GET({ setHeaders }) {
<updated>${feedUpdated.toUTCString()}</updated>
${posts.map((post) => `<item>
<title>${escapeXml(post.title)}</title>
<description><![CDATA[${escapeXml(post.description)}${makeThumbnail(post)}]]></description>
<description><![CDATA[${escapeXml(post.description)}${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>