mirror of
https://github.com/thiloho/thiloho.github.io.git
synced 2025-11-22 10:21:36 +01:00
Add sitemap integration and render robots.txt via ts
This commit is contained in:
@@ -26,9 +26,12 @@ const { title, description } = Astro.props;
|
||||
<link
|
||||
rel="alternate"
|
||||
type="application/rss+xml"
|
||||
title="Your Site's Title"
|
||||
href={new URL("rss.xml", Astro.site)}
|
||||
title="Thilo Hohlt's Blog"
|
||||
href={new URL("rss.xml", Astro.url.origin)}
|
||||
/>
|
||||
<head>
|
||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||
</head>
|
||||
<ClientRouter />
|
||||
<script is:inline>
|
||||
const setTheme = () => {
|
||||
|
||||
12
src/pages/robots.txt.ts
Normal file
12
src/pages/robots.txt.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
const getRobotsTxt = (sitemapURL: URL) => `User-agent: *
|
||||
Allow: /
|
||||
|
||||
Sitemap: ${sitemapURL.href}
|
||||
`;
|
||||
|
||||
export const GET: APIRoute = (context) => {
|
||||
const sitemapURL = new URL("sitemap-index.xml", context.url.origin);
|
||||
return new Response(getRobotsTxt(sitemapURL));
|
||||
};
|
||||
@@ -1,11 +1,11 @@
|
||||
import rss from "@astrojs/rss";
|
||||
import type { APIContext } from "astro";
|
||||
import type { APIRoute } from "astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import sanitizeHtml from "sanitize-html";
|
||||
import MarkdownIt from "markdown-it";
|
||||
const parser = new MarkdownIt();
|
||||
|
||||
export const GET = async (context: APIContext) => {
|
||||
export const GET: APIRoute = async (context) => {
|
||||
const blog = await getCollection("blog");
|
||||
|
||||
const latestModDate = blog.reduce((latest, article) => {
|
||||
|
||||
Reference in New Issue
Block a user