This repository has been archived on 2025-03-28. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coryd.dev-eleventy/src/includes/metadata.liquid

39 lines
No EOL
2.4 KiB
Text

{%- assign fullUrl = globals.url | append: page.url -%}
{%- assign pageTitle = title | default: globals.site_name -%}
{%- assign pageDescription = page.description | default: description | default: globals.site_description -%}
{%- assign ogImage = globals.cdn_url | append: globals.avatar -%}
{%- case schema -%}
{%- when 'blog' -%}
{%- assign pageTitle = post.title -%}
{%- assign pageDescription = post.description | markdown | strip_html | default: globals.site_description -%}
{%- when 'books', 'books-year' -%}
{%- assign featuredBook = books.all | filterBooksByStatus: 'started' | reverse | first -%}
{%- assign ogImage = globals.cdn_url | append: featuredBook.grid.image -%}
{%- if schema == 'books-year' -%}
{%- assign pageTitle = year.value | append: ' / Books / ' | append: globals.site_name -%}
{%- endif -%}
{%- when 'music' -%}
{%- assign ogImage = globals.cdn_url | append: page.image -%}
{%- when 'music-index' -%}
{%- assign pageTitle = 'Music / ' | append: globals.site_name -%}
{%- assign ogImage = globals.cdn_url | append: music.week.artists[0].grid.image -%}
{%- when 'music-period' -%}
{%- assign pageTitle = 'Music / ' | append: page.title | append: ' / ' | append: globals.site_name -%}
{%- when 'page' -%}
{%- assign pageTitle = page.title | append: ' / ' | append: globals.site_name -%}
{%- when 'watching', 'favorite-movies' -%}
{%- assign featuredMovie = movies.recentlyWatched | first -%}
{%- assign ogImage = globals.cdn_url | append: featuredMovie.grid.backdrop -%}
{%- when 'watching-shows', 'favorite-shows' -%}
{%- assign featuredShow = tv.recentlyWatched | first -%}
{%- assign ogImage = globals.cdn_url | append: featuredShow.grid.backdrop -%}
{%- endcase -%}
{%- assign escapedPageDescription = pageDescription | escape -%}
<title data-dynamic="title">{{ pageTitle }}</title>
<link rel="canonical" href="{{ fullUrl }}" />
<meta property="og:title" content="{{ pageTitle }}" data-dynamic="og:title" />
<meta name="description" content="{{ escapedPageDescription }}" data-dynamic="description" />
<meta property="og:description" content="{{ escapedPageDescription }}" data-dynamic="og:description" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{{ fullUrl }}" data-dynamic="og:url" />
<meta property="og:image" content="{{ ogImage }}?class=w800" data-dynamic="og:image" />