feat(*): refactor metadata handling; move metadata to backend where possible, refine client views
This commit is contained in:
parent
929bc9f9f8
commit
9687509e4a
35 changed files with 506 additions and 339 deletions
|
@ -1,103 +1,63 @@
|
|||
{%- assign fullUrl = globals.url | append: page.url -%}
|
||||
{%- assign oembedUrl = globals.url | append: "/oembed" | append: page.url -%}
|
||||
{%- capture appVersionString -%}{% appVersion %}{%- endcapture -%}
|
||||
{%- assign ogImageBaseUrl = globals.url | append: "/og/w800/" | append: appVersionString -%}
|
||||
{%- capture pageTitle -%}
|
||||
{%- if page.title -%}
|
||||
{{ page.title | append: ' • ' | append: globals.site_name }}
|
||||
{%- elsif title -%}
|
||||
{{ title | append: ' • ' | append: globals.site_name }}
|
||||
{%- else -%}
|
||||
{{ globals.site_name }}
|
||||
{%- endif -%}
|
||||
{%- endcapture -%}
|
||||
{%- capture pageDescription -%}
|
||||
{%- if page.description -%}
|
||||
{{ page.description }}
|
||||
{%- elsif description -%}
|
||||
{{ description }}
|
||||
{%- else -%}
|
||||
{{ globals.site_description }}
|
||||
{%- endif -%}
|
||||
{%- endcapture -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: globals.metadata.open_graph_image -%}
|
||||
{%- assign source = page -%}
|
||||
{%- case schema -%}
|
||||
{%- when 'artist' -%}
|
||||
{% render "fetchers/artist.php.liquid" %}
|
||||
{%- when 'genre' -%}
|
||||
{% render "fetchers/genre.php.liquid" %}
|
||||
{%- when 'book' -%}
|
||||
{% render "fetchers/book.php.liquid" %}
|
||||
{%- when 'movie' -%}
|
||||
{% render "fetchers/movie.php.liquid" %}
|
||||
{%- when 'show' -%}
|
||||
{% render "fetchers/show.php.liquid" %}
|
||||
{%- when 'tags' -%}
|
||||
{% render "fetchers/tags.php.liquid" %}
|
||||
{%- when 'artist', 'genre', 'book', 'movie', 'show', 'tags' -%}
|
||||
{% render "fetchers/{{ schema }}.php.liquid" %}
|
||||
{%- when 'blog' -%}
|
||||
{%- assign pageTitle = post.title -%}
|
||||
{%- assign pageDescription = post.description -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: post.metadata.open_graph_image -%}
|
||||
{%- assign source = post -%}
|
||||
{%- when 'music-index', 'music-week-artists' -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: music.week.artists[0].metadata.open_graph_image -%}
|
||||
{%- assign source = music.week.artists[0] -%}
|
||||
{%- when 'music-week-albums', 'music-week-tracks' -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: music.week.albums[0].metadata.open_graph_image -%}
|
||||
{%- assign source = music.week.albums[0] -%}
|
||||
{%- when 'music-month-artists' -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: music.month.artists[0].metadata.open_graph_image -%}
|
||||
{%- assign source = music.month.artists[0] -%}
|
||||
{%- when 'music-month-albums' -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: music.month.albums[0].metadata.open_graph_image -%}
|
||||
{%- assign source = music.month.albums[0] -%}
|
||||
{%- when 'music-releases' -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: albumReleases.upcoming[0].metadata.open_graph_image -%}
|
||||
{%- assign source = albumReleases.upcoming[0] -%}
|
||||
{%- when 'books' -%}
|
||||
{%- assign overviewBook = books.all | filterBooksByStatus: 'started' | reverse | first %}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: overviewBook.metadata.open_graph_image -%}
|
||||
{%- assign source = books.all | filterBooksByStatus: 'started' | reverse | first -%}
|
||||
{%- when 'reading-year' -%}
|
||||
{%- assign pageTitle = 'Books' | append: ' • ' | append: year.value | append: ' • ' | append: globals.site_name -%}
|
||||
{%- capture pageDescription -%}
|
||||
Here's what I read in {{ year.value }}.
|
||||
{%- endcapture -%}
|
||||
{%- assign bookData = year.data | filterBooksByStatus: 'finished' -%}
|
||||
{%- assign bookYear = bookData | shuffleArray | first -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: bookYear.metadata.open_graph_image -%}
|
||||
{%- assign title = 'Books • ' | append: year.value | append: ' • ' | append: globals.site_name -%}
|
||||
{%- assign description = "Here's what I read in " | append: year.value | append: '.' -%}
|
||||
{%- assign bookYear = year.data | filterBooksByStatus: 'finished' | shuffleArray | first -%}
|
||||
{%- assign source = bookYear -%}
|
||||
{%- when 'favorite-movies' -%}
|
||||
{%- assign favoriteMovie = movies.favorites | shuffleArray | first %}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: favoriteMovie.metadata.open_graph_image -%}
|
||||
{%- assign source = movies.favorites | shuffleArray | first -%}
|
||||
{%- when 'favorite-shows' -%}
|
||||
{%- assign favoriteShow = tv.favorites | shuffleArray | first %}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: favoriteShow.metadata.open_graph_image -%}
|
||||
{%- assign source = tv.favorites | shuffleArray | first -%}
|
||||
{%- when 'watching' -%}
|
||||
{%- assign mergedMovies = movies.recentlyWatched | mergeArray: movies.favorites %}
|
||||
{%- assign mergedShows = tv.recentlyWatched | mergeArray: tv.favorites %}
|
||||
{%- assign overviewWatched = mergedMovies | mergeArray: mergedShows | shuffleArray | first -%}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: overviewWatched.metadata.open_graph_image -%}
|
||||
{%- assign mergedMovies = movies.recentlyWatched | mergeArray: movies.favorites -%}
|
||||
{%- assign mergedShows = tv.recentlyWatched | mergeArray: tv.favorites -%}
|
||||
{%- assign source = mergedMovies | mergeArray: mergedShows | shuffleArray | first -%}
|
||||
{%- when 'upcoming-shows' -%}
|
||||
{%- assign upcomingShow = upcomingShows.watching | shuffleArray | first %}
|
||||
{%- assign ogImage = ogImageBaseUrl | append: upcomingShow.metadata.open_graph_image -%}
|
||||
{%- when 'page' -%}
|
||||
{%- assign pageDescription = page.description -%}
|
||||
{% endcase %}
|
||||
{%- assign source = upcomingShows.watching | shuffleArray | first -%}
|
||||
{%- endcase %}
|
||||
{%- assign meta = source | getMetadata: globals, page, title, description, schema -%}
|
||||
{%- assign fullUrl = meta.url -%}
|
||||
{%- assign oembedUrl = globals.url | append: "/oembed" | append: page.url -%}
|
||||
{%- if type == 'dynamic' -%}
|
||||
{% render "metadata/dynamic.php.liquid"
|
||||
fullUrl:fullUrl,
|
||||
oembedUrl:oembedUrl,
|
||||
pageTitle:pageTitle,
|
||||
pageDescription:pageDescription,
|
||||
ogImage:globals.metadata.open_graph_image,
|
||||
globals:globals,
|
||||
%}
|
||||
{% render "metadata/dynamic.php.liquid"
|
||||
fullUrl: fullUrl,
|
||||
oembedUrl: oembedUrl,
|
||||
pageTitle: meta.title,
|
||||
pageDescription: meta.description,
|
||||
ogImage: meta.open_graph_image,
|
||||
globals: globals,
|
||||
%}
|
||||
{%- else -%}
|
||||
{% render "metadata/static.liquid"
|
||||
fullUrl:fullUrl,
|
||||
oembedUrl:oembedUrl,
|
||||
pageTitle:pageTitle,
|
||||
pageDescription:pageDescription,
|
||||
ogImage:ogImage,
|
||||
globals:globals,
|
||||
%}
|
||||
{%- endif -%}
|
||||
{% render "metadata/static.liquid"
|
||||
fullUrl: fullUrl,
|
||||
oembedUrl: oembedUrl,
|
||||
pageTitle: meta.title,
|
||||
pageDescription: meta.description,
|
||||
ogImage: meta.open_graph_image,
|
||||
globals: globals,
|
||||
%}
|
||||
{%- endif %}
|
||||
{% render "metadata/base.liquid"
|
||||
pageTitle:pageTitle,
|
||||
globals:globals,
|
||||
eleventy:eleventy,
|
||||
appVersion:appVersion,
|
||||
pageTitle: meta.title,
|
||||
globals: globals,
|
||||
eleventy: eleventy,
|
||||
appVersion: appVersion,
|
||||
%}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue