Compare commits
No commits in common. "3190a5b61d22792683542831851c7afaafb25ca2" and "6a60ce55e560b75d01ec2a1833c659aedd3d5518" have entirely different histories.
3190a5b61d
...
6a60ce55e5
5 changed files with 1 additions and 74 deletions
|
|
@ -1,10 +0,0 @@
|
||||||
---
|
|
||||||
title: 'Наш первый блог'
|
|
||||||
thumbnail: 'wasd_perelesoq_game_jam_2025.png'
|
|
||||||
date: '2025-09-19'
|
|
||||||
description: 'Немного о самом сайте'
|
|
||||||
---
|
|
||||||
|
|
||||||
# ПРИВЕТ !
|
|
||||||
|
|
||||||
Добро пожаловать на наш первый блог-пост!
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
export async function fetchPostsSorted() {
|
|
||||||
const allPosts = await fetchPosts();
|
|
||||||
|
|
||||||
const sortedPosts = allPosts.sort((a, b) => {
|
|
||||||
return new Date(b.date).valueOf() - new Date(a.date).valueOf();
|
|
||||||
});
|
|
||||||
|
|
||||||
return sortedPosts;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function fetchPosts() {
|
|
||||||
const allPostFiles = import.meta.glob('/src/blogs/*.md');
|
|
||||||
const iterablePostFiles = Object.entries(allPostFiles);
|
|
||||||
|
|
||||||
const allPosts: App.BlogPost[] = await Promise.all(
|
|
||||||
iterablePostFiles.map(async ([filePath, resolver]) => {
|
|
||||||
const { metadata }: any = await resolver();
|
|
||||||
const { name } = path.parse(filePath);
|
|
||||||
|
|
||||||
return {
|
|
||||||
slug: name,
|
|
||||||
...metadata
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return allPosts;
|
|
||||||
};
|
|
||||||
|
|
@ -45,7 +45,7 @@ function getIconFromUrl(url: URL): string | undefined {
|
||||||
const href = url.href;
|
const href = url.href;
|
||||||
if (href.startsWith('mailto:'))
|
if (href.startsWith('mailto:'))
|
||||||
return 'email';
|
return 'email';
|
||||||
if (href.endsWith('/rss.xml') || href.endsWith('/atom.rss'))
|
if (href.endsWith('/rss.xml'))
|
||||||
return 'rss';
|
return 'rss';
|
||||||
|
|
||||||
const hostname = url.hostname;
|
const hostname = url.hostname;
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
import { fetchPostsSorted } from "$src/lib/util/Blogs";
|
|
||||||
|
|
||||||
function escapeXml(unsafe: string): string {
|
|
||||||
return unsafe
|
|
||||||
.replace(/&/g, "&")
|
|
||||||
.replace(/</g, "<")
|
|
||||||
.replace(/>/g, ">")
|
|
||||||
.replace(/"/g, """)
|
|
||||||
.replace(/'/g, "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function GET({ setHeaders }) {
|
|
||||||
setHeaders({
|
|
||||||
'Cache-Control': 'max-age=0, s-maxage=3600',
|
|
||||||
'Content-Type': 'application/rss+xml',
|
|
||||||
});
|
|
||||||
const posts = await fetchPostsSorted();
|
|
||||||
return new Response(String(`<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<rss xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:atom="https://www.w3.org/2005/Atom" version="2.0">
|
|
||||||
<channel>
|
|
||||||
<title>Блог Tea Sanctuary</title>
|
|
||||||
<link>https://teasanctuary.ru/blog</link>
|
|
||||||
<ttl>1800</ttl>
|
|
||||||
${posts.map((post) => `<item>
|
|
||||||
<title>${escapeXml(post.title)}</title>
|
|
||||||
<description>${escapeXml(post.description)}</description>
|
|
||||||
<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>
|
|
||||||
</item>`).join("\n")}
|
|
||||||
</channel>
|
|
||||||
</rss>`))
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 449 KiB |
Loading…
Add table
Add a link
Reference in a new issue