chore: deduplicate permalinks; fix sitemap; organize

This commit is contained in:
Cory Dransfeldt 2024-07-15 22:52:57 -07:00
parent b40986256a
commit ae1cb3dc5e
No known key found for this signature in database
64 changed files with 94 additions and 31 deletions

View file

@ -1,5 +1,5 @@
import { createClient } from '@supabase/supabase-js'
import { parseCountryField } from '../../config/utilities/index.js'
import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js'
const SUPABASE_URL = process.env.SUPABASE_URL
const SUPABASE_KEY = process.env.SUPABASE_KEY
@ -72,6 +72,7 @@ export default async function () {
artist['image'] = `/${artist['art']['filename_disk']}`
artist['country'] = parseCountryField(artist['country'])
artist['genres'] = genreMapping[artist['genres']] || ''
artist['url'] = `/music/artists/${sanitizeMediaString(artist['name_string'])}-${sanitizeMediaString(artist['country'])}`
}
return artists

View file

@ -1,4 +1,5 @@
import { createClient } from '@supabase/supabase-js'
import slugify from 'slugify'
import { parseCountryField } from '../../config/utilities/index.js'
const SUPABASE_URL = process.env.SUPABASE_URL
@ -34,6 +35,7 @@ const fetchGenresWithArtists = async () => {
...artist,
country: parseCountryField(artist['country'])
}))
genre['url'] = `/music/genres/${slugify(genre['name'].toLowerCase())}`
})
return data

View file

@ -48,7 +48,8 @@ const prepareShowData = (show) => {
return {
...show,
image: show['art']?.['filename_disk'] ? `/${show['art']['filename_disk']}` : '',
backdrop: show['backdrop']?.['filename_disk'] ? `/${show['backdrop']['filename_disk']}` : ''
backdrop: show['backdrop']?.['filename_disk'] ? `/${show['backdrop']['filename_disk']}` : '',
url: `/watching/shows/${show['tmdb_id']}`,
}
}
@ -121,24 +122,24 @@ export default async function () {
sortedShows.forEach(show => {
const startingEpisode = show['episodes'][show['episodes'].length - 1]['episode']
const startingSeason = show['episodes'][show['episodes'].length - 1]['season']
const endingEpisode = show['episodes'][0].episode
const endingSeason = show['episodes'][0].season
const endingEpisode = show['episodes'][0]['episode']
const endingSeason = show['episodes'][0]['season']
if (show['episodes'].length > 1) {
episodeData.push({
name: show.title,
url: `/watching/shows/${show.tmdbId}`,
name: show['title'],
url: `/watching/shows/${show['tmdbId']}`,
subtext: `S${startingSeason}E${startingEpisode} - S${endingSeason}E${endingEpisode}`,
startingEpisode,
startingSeason,
episode: endingEpisode,
season: endingSeason,
tmdbId: show.tmdbId,
collected: show.collected,
favorite: show.favorite,
tmdbId: show['tmdbId'],
collected: show['collected'],
favorite: show['favorite'],
type: 'tv-range',
image: show.image,
backdrop: show.backdrop
image: show['image'],
backdrop: show['backdrop']
})
} else {
const singleEpisode = show['episodes'][0]

View file

@ -4,14 +4,12 @@ eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for page in collections.all %}
{% if not page.data.draft %}
<url>
<loc>{{ globals.url }}{{ page.url }}</loc>
<lastmod>{{ page.date | isoDateOnly: '-' }}</lastmod>
<changefreq>{%- if page.data.changeFreq -%}{{ page.data.changeFreq }}{%- else -%}monthly{%- endif -%}</changefreq>
<priority>{%- if page.data.priority -%}{{ page.data.priority }}{%- else -%}0.5{%- endif %}</priority>
</url>
{% endif %}
{% for page in collections.siteMap %}
<url>
<loc>{{ globals.url }}{{ page.url }}</loc>
<lastmod>{{ page.date | date: '%Y-%m-%d' }}</lastmod>
<changefreq>{% if page.data.changeFreq %}{{ page.data.changeFreq }}{% else %}monthly{% endif %}</changefreq>
<priority>{% if page.data.priority %}{{ page.data.priority }}{% else %}0.5{% endif %}</priority>
</url>
{% endfor %}
</urlset>

View file

@ -4,7 +4,7 @@ pagination:
data: books.all
size: 1
alias: book
permalink: "/books/{{ book.isbn }}/index.html"
permalink: "{{ book.url }}/index.html"
isbn: {{ book.isbn }}
schema: book
---
@ -50,6 +50,7 @@ schema: book
</div>
{% if book.review %}
{% render "partials/blocks/banners/warning.liquid", text: "There are probably spoilers after this banner — this is a warning about them." %}
<h3>My thoughts</h3>
{{ book.review | markdown }}
<hr />
{% endif %}

View file

@ -4,7 +4,7 @@ pagination:
data: artists
size: 1
alias: artist
permalink: "/music/artists/{{ artist.name_string | sanitizeMediaString }}-{{ artist.country | sanitizeMediaString }}/index.html"
permalink: "{{ artist.url }}/index.html"
updated: "now"
schema: artist
---

View file

@ -4,7 +4,7 @@ pagination:
data: genres
size: 1
alias: genre
permalink: "/music/genres/{{ genre.name | slugify | downcase }}/index.html"
permalink: "{{ genre.url }}/index.html"
updated: "now"
schema: genre
---

View file

@ -4,7 +4,7 @@ pagination:
data: movies.movies
size: 1
alias: movie
permalink: /watching/movies/{{ movie.id }}/index.html
permalink: "{{ movie.url }}/index.html"
schema: movie
---
{%- capture alt -%}
@ -39,6 +39,7 @@ schema: movie
</div>
{% if movie.review %}
{% render "partials/blocks/banners/warning.liquid", text: "There are probably spoilers after this banner — this is a warning about them." %}
<h3>My thoughts</h3>
{{ movie.review | markdown }}
<hr />
{% endif %}

View file

@ -4,7 +4,7 @@ pagination:
data: tv.shows
size: 1
alias: show
permalink: /watching/shows/{{ show.tmdb_id }}/index.html
permalink: "{{ show.url }}/index.html"
schema: show
---
{%- capture alt -%}
@ -38,6 +38,8 @@ schema: show
<p class="sub-meta"><a href="https://themoviedb.org/tv/{{ show.tmdb_id }}" title="View {{ show.title | escape }} on TMDB">View on TMDB</a></p>
</div>
{% if show.review %}
{% render "partials/blocks/banners/warning.liquid", text: "There are probably spoilers after this banner — this is a warning about them." %}
<h3>My thoughts</h3>
{{ show.review | markdown }}
<hr />
{% endif %}