mirror of
https://github.com/michaelrausch/michaelrausch-24.git
synced 2024-12-03 10:33:08 +00:00
Added redirects
This commit is contained in:
parent
bf91b37f81
commit
4a776d6a4b
@ -14,11 +14,12 @@ interface Props {
|
||||
title: string;
|
||||
description: string;
|
||||
image?: string;
|
||||
redirect?: string;
|
||||
}
|
||||
|
||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
||||
|
||||
const { title, description, image = "/nano.png" } = Astro.props;
|
||||
const { title, description, image = "/nano.png", redirect } = Astro.props;
|
||||
---
|
||||
|
||||
<!-- Global Metadata -->
|
||||
@ -57,6 +58,13 @@ const { title, description, image = "/nano.png" } = Astro.props;
|
||||
<meta property="twitter:description" content={description} />
|
||||
<meta property="twitter:image" content={new URL(image, Astro.url)} />
|
||||
|
||||
{redirect ? (
|
||||
<meta
|
||||
http-equiv="refresh"
|
||||
content={ `0; url=${ redirect }` }
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<ViewTransitions />
|
||||
|
||||
<script>
|
||||
|
@ -32,4 +32,12 @@ const projects = defineCollection({
|
||||
}),
|
||||
});
|
||||
|
||||
export const collections = { blog, work, projects };
|
||||
const redirects = defineCollection({
|
||||
type: "content",
|
||||
schema: z.object({
|
||||
title: z.string(),
|
||||
redirect: z.string(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const collections = { blog, work, projects, redirects };
|
||||
|
4
src/content/redirects/facebook/index.md
Normal file
4
src/content/redirects/facebook/index.md
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: "Facebook"
|
||||
redirect: "https://www.facebook.com/michael.rausch123/"
|
||||
---
|
4
src/content/redirects/github/index.md
Normal file
4
src/content/redirects/github/index.md
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: "Github"
|
||||
redirect: "https://github.com/michaelrausch"
|
||||
---
|
4
src/content/redirects/instagram/index.md
Normal file
4
src/content/redirects/instagram/index.md
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: "Instagram"
|
||||
redirect: "https://www.instagram.com/michaelnz_"
|
||||
---
|
@ -7,15 +7,16 @@ import { SITE } from "@consts";
|
||||
type Props = {
|
||||
title: string;
|
||||
description: string;
|
||||
redirect?: string;
|
||||
};
|
||||
|
||||
const { title, description } = Astro.props;
|
||||
const { title, description, redirect } = Astro.props;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<Head title={`${title} | ${SITE.NAME}`} description={description} />
|
||||
<Head title={`${title} | ${SITE.NAME}`} description={description} redirect={redirect}/>
|
||||
</head>
|
||||
<body>
|
||||
<Header />
|
||||
|
23
src/pages/go/[...slug].astro
Normal file
23
src/pages/go/[...slug].astro
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import PageLayout from "@layouts/PageLayout.astro";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const redirects = (await getCollection("redirects"))
|
||||
|
||||
return redirects.map((redirect) => ({
|
||||
params: { slug: redirect.slug },
|
||||
props: redirect,
|
||||
}));
|
||||
}
|
||||
type Props = CollectionEntry<"redirects">;
|
||||
|
||||
const redirect = Astro.props;
|
||||
const { Content } = await redirect.render();
|
||||
---
|
||||
|
||||
<PageLayout title={redirect.data.title} description={redirect.data.title} redirect={redirect.data.redirect}>
|
||||
<div class="text-center mt-10">
|
||||
<p class="text-xl">Redirecting to {redirect.data.title}...</p>
|
||||
</div>
|
||||
</PageLayout>
|
9
src/pages/go/index.astro
Normal file
9
src/pages/go/index.astro
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
import PageLayout from "@layouts/PageLayout.astro";
|
||||
|
||||
const redirect = "/"
|
||||
---
|
||||
|
||||
<PageLayout title="Redirect..." description="Redirect" redirect={redirect}>
|
||||
|
||||
</PageLayout>
|
Loading…
Reference in New Issue
Block a user