Блоги #1
1 changed files with 21 additions and 1 deletions
|
|
@ -21,6 +21,26 @@ function makeThumbnail(post: App.BlogPost): string {
|
||||||
return `<br><br><img src="https://teasanctuary.ru${resolveBlogPath(post.slug, post.thumbnail)}"${alt}>`;
|
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 }) {
|
export async function GET({ setHeaders }) {
|
||||||
setHeaders({
|
setHeaders({
|
||||||
'Cache-Control': 'max-age=0, s-maxage=3600',
|
'Cache-Control': 'max-age=0, s-maxage=3600',
|
||||||
|
|
@ -36,7 +56,7 @@ export async function GET({ setHeaders }) {
|
||||||
<updated>${feedUpdated.toUTCString()}</updated>
|
<updated>${feedUpdated.toUTCString()}</updated>
|
||||||
${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>
|
<description><![CDATA[${escapeXml(post.description)}${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