feat: add opentags
All checks were successful
Deploy to SFTP Server / build (push) Successful in 4m0s

This commit is contained in:
max_richter 2025-02-18 16:23:51 +01:00
parent 19a703367d
commit 6aa6ddabb0
7 changed files with 39 additions and 3 deletions

View File

@ -0,0 +1,13 @@
---
interface Props {
title: string;
cover: string;
}
---
<meta property="og:title" content={Astro.props.title} />
<meta property="og:type" content="website" />
<meta property="og:url" content={Astro.url} />
<meta property="og:image" content={Astro.props.cover} />
<meta property="og:description" content="Max Richters personal blog" />
<meta property="og:site_name" content="Max Richter" />

View File

@ -6,10 +6,12 @@ import { useTranslations } from "@i18n/utils";
interface Props { interface Props {
title: string; title: string;
width?: "full" | "compact"; width?: "full" | "compact";
image?: string;
} }
const t = useTranslations(Astro.url); const t = useTranslations(Astro.url);
const { title } = Astro.props; const { title } = Astro.props;
import "./theme.css"; import "./theme.css";
import "./global.css"; import "./global.css";
--- ---
@ -21,6 +23,7 @@ import "./global.css";
<meta name="description" content="Astro description" /> <meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="props" content={JSON.stringify(Astro.props)} /> <meta name="props" content={JSON.stringify(Astro.props)} />
<link rel="sitemap" href="/sitemap-index.xml" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<script <script
is:inline is:inline
@ -60,7 +63,7 @@ import "./global.css";
]} ]}
/> />
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<!-- <meta http-equiv="refresh" content="0;url=/" /> --> <slot name="meta-tags" />
<title>{title}</title> <title>{title}</title>
<script is:inline> <script is:inline>
(function () { (function () {

View File

@ -9,11 +9,12 @@ type Props = MarkdownLayoutProps<{
date: Date; date: Date;
links?: string[][]; links?: string[][];
toc?: boolean; toc?: boolean;
cover?: string;
}>; }>;
const { frontmatter, headings } = Astro.props; const { frontmatter, headings } = Astro.props;
const t = useTranslations(Astro.url); const t = useTranslations(Astro.url);
const { title, url, date: dateString, links, toc } = frontmatter; const { title, url, date: dateString, links, toc, cover } = frontmatter;
const collection = url?.split("/")[2]; const collection = url?.split("/")[2];
const date = new Date(dateString); const date = new Date(dateString);
const path = useTranslatedPath(Astro.url); const path = useTranslatedPath(Astro.url);
@ -22,7 +23,7 @@ const path = useTranslatedPath(Astro.url);
const backlinkContent = t(`nav.${collection}`).toLowerCase(); const backlinkContent = t(`nav.${collection}`).toLowerCase();
--- ---
<Layout title={title}> <Layout title={title} image={cover}>
<div class="top-info flex items-center place-content-between m-y-2"> <div class="top-info flex items-center place-content-between m-y-2">
<a class="flex items-center gap-1 opacity-50" href={path("/" + collection)} <a class="flex items-center gap-1 opacity-50" href={path("/" + collection)}
><span class="i-tabler-arrow-left"></span> ><span class="i-tabler-arrow-left"></span>

View File

@ -2,6 +2,7 @@
import { getCollection, render } from "astro:content"; import { getCollection, render } from "astro:content";
import { getLocale } from "astro-i18n-aut"; import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils"; import { filterCollection, parseSlug } from "@i18n/utils";
import MetaTags from "@components/MetaTags.astro";
const locale = getLocale(Astro.url); const locale = getLocale(Astro.url);
@ -31,4 +32,5 @@ if (!page) {
const { Content } = await render(page); const { Content } = await render(page);
--- ---
<MetaTags title={page.data.title} cover={page.data.cover?.src} />
<Content /> <Content />

View File

@ -2,6 +2,7 @@
import { getCollection, render } from "astro:content"; import { getCollection, render } from "astro:content";
import { getLocale } from "astro-i18n-aut"; import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils"; import { filterCollection, parseSlug } from "@i18n/utils";
import MetaTags from "@components/MetaTags.astro";
const locale = getLocale(Astro.url); const locale = getLocale(Astro.url);
@ -31,4 +32,5 @@ if (!page) {
const { Content } = await render(page); const { Content } = await render(page);
--- ---
<MetaTags title={page.data.title} cover={page.data.cover?.src} />
<Content /> <Content />

View File

@ -2,6 +2,7 @@
import { getCollection, render } from "astro:content"; import { getCollection, render } from "astro:content";
import { getLocale } from "astro-i18n-aut"; import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils"; import { filterCollection, parseSlug } from "@i18n/utils";
import MetaTags from "@components/MetaTags.astro";
const locale = getLocale(Astro.url); const locale = getLocale(Astro.url);
@ -31,4 +32,5 @@ if (!page) {
const { Content } = await render(page); const { Content } = await render(page);
--- ---
<MetaTags title={page.data.title} cover={page.data.cover?.src} />
<Content /> <Content />

13
src/pages/robots.txt.ts Normal file
View File

@ -0,0 +1,13 @@
import type { APIRoute } from 'astro';
const getRobotsTxt = (sitemapURL: URL) => `
User-agent: *
Allow: /
Sitemap: ${sitemapURL.href}
`;
export const GET: APIRoute = ({ site }) => {
const sitemapURL = new URL('sitemap-index.xml', site);
return new Response(getRobotsTxt(sitemapURL));
};