This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-eleventy/src/includes/base.liquid

158 lines
No EOL
8.4 KiB
Text

{%- assign fullUrl = globals.url | append: page.url -%}
{%- assign pageTitle = globals.site_name -%}
{%- if schema == 'blog' -%}
{%- assign pageTitle = post.title -%}
{%- elsif title -%}
{%- assign pageTitle = title | append: ' / ' | append: globals.site_name -%}
{%- elsif artist.name -%}
{%- assign pageTitle = 'Artists / ' | append: artist.name | append: ' / ' | append: globals.site_name -%}
{%- elsif schema == 'music-index' -%}
{%- assign pageTitle = 'Music / ' | append: globals.site_name -%}
{%- elsif schema == 'music-period' -%}
{%- assign pageTitle = 'Music / ' | append: page.title | append: globals.site_name -%}
{%- elsif genre.name -%}
{%- assign pageTitle = 'Music / ' | append: genre.name | append: ' / ' | append: globals.site_name -%}
{%- elsif book.title -%}
{%- assign pageTitle = 'Books / ' | append: book.title | append: ' / ' | append: globals.site_name -%}
{%- elsif year.value -%}
{%- assign pageTitle = ' / Books ' | prepend: year.value | append: ' / ' | append: globals.site_name -%}
{%- elsif movie.title -%}
{%- assign pageTitle = 'Movies / ' | append: movie.title -%}
{%- if movie.rating -%}
{%- assign pageTitle = pageTitle | append: ' (' | append: movie.rating | append: ')' -%}
{%- endif -%}
{%- assign pageTitle = pageTitle | append: ' / ' | append: globals.site_name -%}
{%- elsif show.title -%}
{%- assign pageTitle = 'Shows / ' | append: show.title | append: ' / ' | append: globals.site_name -%}
{%- elsif page.description -%}
{%- assign pageTitle = page.title | append: ' / ' | append: globals.site_name -%}
{%- endif -%}
{%- assign pageDescription = globals.site_description -%}
{%- if schema == 'blog' -%}
{%- assign pageDescription = post.description | markdown | strip_html -%}
{%- elsif artist.description -%}
{%- assign pageDescription = artist.description | truncate: 300 -%}
{%- elsif book.description -%}
{%- assign pageDescription = book.review | markdown | strip_html | default: book.description | truncate: 300 -%}
{%- elsif movie.description -%}
{%- assign pageDescription = movie.review | markdown | strip_html | default: movie.description | truncate: 300 -%}
{%- elsif show.description -%}
{%- assign pageDescription = show.review | markdown | strip_html | default: show.description | truncate: 300 -%}
{%- elsif genre.description -%}
{%- assign pageDescription = genre.description | markdown | strip_html | truncate: 300 -%}
{%- elsif page.description -%}
{%- assign pageDescription = page.description -%}
{%- elsif description -%}
{%- assign pageDescription = description -%}
{%- endif -%}
{%- assign ogImage = 'https://cdn.coryd.dev/' | append: globals.opengraph_default -%}
{%- case schema -%}
{%- when 'music' -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: page.image -%}
{%- when 'music-index' -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: music.week.artists[0].image -%}
{%- when 'artist' -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: artist.image -%}
{%- when 'genre' -%}
{%- assign sortedGenreArtists = genre.artists | sortByPlaysDescending: "total_plays" -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: sortedGenreArtists[0].image -%}
{%- when 'watching' -%}
{%- assign featuredMovie = movies.recentlyWatched | first -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: featuredMovie.backdrop -%}
{%- when 'books' -%}
{%- assign featuredBook = books.all | bookStatus: 'started' | reverse | first -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: featuredBook.image -%}
{%- when 'books-year' -%}
{%- assign featuredBook = books.all | bookStatus: 'finished' | bookFinishedYear: year.value | bookSortDescending | first -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: featuredBook.image -%}
{%- when 'book' -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: book.image -%}
{%- when 'movie' -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: movie.backdrop -%}
{%- when 'show' -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: show.backdrop -%}
{%- when 'genre' -%}
{%- assign genreArtist = genre.artists | shuffleArray | first -%}
{%- assign ogImage = 'https://cdn.coryd.dev' | append: genreArtist.image -%}
{%- endcase -%}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{{ pageTitle }}</title>
<link rel="preload" href="/assets/fonts/MonoLisa.min.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="stylesheet" href="/assets/styles/index.css?v={% appVersion %}" type="text/css" />
<link rel="canonical" href="{{ fullUrl }}" />
<meta property="og:title" content="{{ pageTitle }}" />
<meta name="description" content="{{ pageDescription }}" />
<meta property="og:description" content="{{ pageDescription }}" />
<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="@cory@social.lol" />
<meta name="generator" content="Eleventy">
<meta name="robots" content="noai, noimageai">
<link href="https://cdn.coryd.dev/{{ globals.favicon_ico }}?class=w50&v={% appVersion %}" rel="icon" sizes="any">
<link href="https://cdn.coryd.dev/{{ globals.favicon_svg }}?class=w50&v={% appVersion %}" rel="icon" type="image/svg+xml">
<link href="https://cdn.coryd.dev/{{ globals.apple_touch_icon }}?class=w200&v={% appVersion %}" rel="apple-touch-icon">
<link rel="webmention" href="https://webmention.io/coryd.dev/webmention" />
<link rel="pingback" href="https://webmention.io/coryd.dev/xmlrpc" />
<link type="application/atom+xml" rel="alternate" title="Posts / {{ globals.site_name }}" href="https://coryd.dev/feeds/posts">
<link rel="alternate" href="https://coryd.dev/feeds/links" title="Links / {{ globals.site_name }}" type="application/rss+xml">
<link rel="alternate" href="https://coryd.dev/feeds/movies" title="Movies / {{ globals.site_name }}'s movies feed" type="application/rss+xml">
<link rel="alternate" href="https://coryd.dev/feeds/books" title="Books / {{ globals.site_name }}" type="application/rss+xml">
<link rel="alternate" href="https://coryd.dev/feeds/all" title="All activity / {{ globals.site_name }}" type="application/rss+xml">
<script defer src="/assets/scripts/index.js?v={% appVersion %}"></script>
<script defer src="/js/script.js?v={% appVersion %}" data-website-id="f405b664-258b-4d77-bd42-94ccf6b294f5"></script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "WebSite",
"@id": "{{ globals.url }}#website",
"url": "{{ globals.url }}",
"name": "{{ pageTitle }}",
"description": "{{ pageDescription }}",
"inLanguage": "{{ globals.locale }}"
},
{%- if schema == 'blog' -%}
{
"@type": "BlogPosting",
"mainEntityOfPage": { "@type": "WebPage" },
"isPartOf": { "@id": "{{ globals.url }}#website" },
"@id": "{{ fullUrl }}",
"headline": "{{ pageTitle }}",
"description": "{{ pageDescription }}",
"image": "{{ image | default: globals.meta_data.opengraph_default }}",
"inLanguage": "{{ globals.locale }}",
"publisher": { "@type": "{{ globals.site_type }}", "name": "{{ globals.author }}", "url": "{{ globals.url }}" },
"author": { "@type": "Person", "name": "{{ globals.author }}" },
"datePublished": "{{ page.date | isoDateOnly: '.' }}"
}
{%- endif -%}
]
}
</script>
<noscript>
<style>.client-side {display:none}</style>
</noscript>
</head>
<body>
<script>
(() => {
const currentTheme = sessionStorage?.getItem('theme')
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches
const root = document.getElementsByTagName('html')[0]
if (!currentTheme) sessionStorage?.setItem('theme', (prefersDarkScheme ? 'dark' : 'light'))
root.classList.add(`theme__${currentTheme || (prefersDarkScheme ? 'dark' : 'light')}`)
})()
</script>
{{ content }}
</body>
</html>