feat: numerous other pages
This commit is contained in:
parent
159b60b3fb
commit
ca34a11ad4
54 changed files with 1074 additions and 101 deletions
155
src/components/Metadata.astro
Normal file
155
src/components/Metadata.astro
Normal file
|
@ -0,0 +1,155 @@
|
|||
---
|
||||
const {
|
||||
schema,
|
||||
page,
|
||||
globals,
|
||||
post,
|
||||
title,
|
||||
description,
|
||||
artist,
|
||||
movie,
|
||||
movies,
|
||||
show,
|
||||
tv,
|
||||
book,
|
||||
books,
|
||||
genre,
|
||||
year,
|
||||
} = Astro.props;
|
||||
|
||||
const fullUrl = `${globals.url}${page.url}`;
|
||||
let pageTitle = globals.site_name;
|
||||
let pageDescription = globals.site_description;
|
||||
let ogImage = `${globals.cdn_url}${globals.avatar}`;
|
||||
|
||||
switch (schema) {
|
||||
case "blog":
|
||||
pageTitle = post?.title || pageTitle;
|
||||
pageDescription = post?.description || pageDescription;
|
||||
ogImage = `${globals.cdn_url}${post?.image}`;
|
||||
break;
|
||||
case "music":
|
||||
case "music-index":
|
||||
case "music-period":
|
||||
pageTitle = schema === "music" ? `Music / ${page.title}` : "Music";
|
||||
if (schema === "music") {
|
||||
ogImage = `${globals.cdn_url}${page?.image}`;
|
||||
} else if (schema === "music-index") {
|
||||
ogImage = `${globals.cdn_url}${movies?.week?.artists[0]?.grid?.image}`;
|
||||
} else if (schema === "music-period") {
|
||||
ogImage = `${globals.cdn_url}${page?.image}`;
|
||||
}
|
||||
break;
|
||||
case "artist":
|
||||
pageTitle = `Artists / ${artist?.name}`;
|
||||
pageDescription = artist?.description || pageDescription;
|
||||
ogImage = `${globals.cdn_url}${artist?.image}`;
|
||||
break;
|
||||
case "genre":
|
||||
pageTitle = `Music / ${genre?.name}`;
|
||||
pageDescription = genre?.description || pageDescription;
|
||||
ogImage = `${globals.cdn_url}${genre?.artists[0]?.image}`;
|
||||
break;
|
||||
case "book":
|
||||
pageTitle = `Books / ${book?.title} by ${book?.author}`;
|
||||
pageDescription = book?.review || book?.description || pageDescription;
|
||||
ogImage = `${globals.cdn_url}${book?.image}`;
|
||||
break;
|
||||
case "books":
|
||||
pageTitle = "Books";
|
||||
const overviewBook = books?.all?.find((b) => b.status === "started");
|
||||
ogImage = `${globals.cdn_url}${overviewBook?.image}`;
|
||||
break;
|
||||
case "books-year":
|
||||
const bookYear = year?.data?.find((b) => b.status === "finished");
|
||||
ogImage = `${globals.cdn_url}${bookYear?.image}`;
|
||||
break;
|
||||
case "movie":
|
||||
pageTitle = `Movies / ${movie?.title}`;
|
||||
if (movie?.rating) {
|
||||
pageTitle += ` (${movie.rating})`;
|
||||
}
|
||||
pageDescription = movie?.review || movie?.description || pageDescription;
|
||||
ogImage = `${globals.cdn_url}${movie?.backdrop}`;
|
||||
break;
|
||||
case "favorite-movies":
|
||||
pageTitle = "Favorite movies";
|
||||
const favoriteMovie = movies?.favorites?.[0];
|
||||
ogImage = `${globals.cdn_url}${favoriteMovie?.backdrop}`;
|
||||
break;
|
||||
case "show":
|
||||
pageTitle = `Show / ${show?.title}`;
|
||||
pageDescription = show?.review || show?.description || pageDescription;
|
||||
ogImage = `${globals.cdn_url}${show?.backdrop}`;
|
||||
break;
|
||||
case "favorite-shows":
|
||||
pageTitle = "Favorite shows";
|
||||
const favoriteShow = tv?.favorites?.[0];
|
||||
ogImage = `${globals.cdn_url}${favoriteShow?.backdrop}`;
|
||||
break;
|
||||
case "watching":
|
||||
pageTitle = "Watching";
|
||||
const overviewMovie = movies?.recentlyWatched?.[0];
|
||||
ogImage = `${globals.cdn_url}${overviewMovie?.backdrop}`;
|
||||
break;
|
||||
case "page":
|
||||
pageTitle = page?.title || pageTitle;
|
||||
pageDescription = page?.description || pageDescription;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (title) pageTitle = title;
|
||||
if (description) pageDescription = description;
|
||||
if (pageTitle !== globals.site_name && schema !== "blog") pageTitle = `${pageTitle} / ${globals.site_name}`;
|
||||
|
||||
const escapedPageDescription =
|
||||
pageDescription?.replace(
|
||||
/["'<>&]/g,
|
||||
(c) =>
|
||||
({
|
||||
'"': """,
|
||||
"'": "'",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
"&": "&",
|
||||
})[c]
|
||||
) || "";
|
||||
---
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="color-scheme" content="light dark" />
|
||||
<title>{pageTitle}</title>
|
||||
<link rel="canonical" href={fullUrl} />
|
||||
<meta property="og:title" content={pageTitle} />
|
||||
<meta name="description" content={escapedPageDescription} />
|
||||
<meta property="og:description" content={escapedPageDescription} />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content={fullUrl} />
|
||||
<meta property="og:image" content={`${ogImage}?class=w800`} />
|
||||
<meta name="theme-color" content={globals.theme_color} />
|
||||
<meta name="fediverse:creator" content={globals.mastodon} />
|
||||
<meta name="generator" content="Astro" />
|
||||
<meta name="robots" content="noai, noimageai" />
|
||||
<link
|
||||
href={`${globals.cdn_url}${globals.avatar_transparent}?class=w50`}
|
||||
rel="icon"
|
||||
sizes="any"
|
||||
/>
|
||||
<link
|
||||
href={`${globals.cdn_url}${globals.avatar_transparent}?class=w50&type=svg`}
|
||||
rel="icon"
|
||||
type="image/svg+xml"
|
||||
/>
|
||||
<link
|
||||
href={`${globals.cdn_url}${globals.avatar}?class=w800`}
|
||||
rel="apple-touch-icon"
|
||||
/>
|
||||
<link
|
||||
type="application/atom+xml"
|
||||
rel="alternate"
|
||||
title={`Posts / ${globals.site_name}`}
|
||||
href="https://coryd.dev/feeds/posts"
|
||||
/>
|
Reference in a new issue