Fixed bug in edit-on.njk, hopefully. Initial pass at mixes.
This commit is contained in:
parent
259a770b3d
commit
1d2b0b4629
8 changed files with 90 additions and 4 deletions
|
|
@ -15,7 +15,7 @@ dotenv.config();
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
|
|
||||||
// config import
|
// config import
|
||||||
import {getAllPosts, showInSitemap, tagList} from './src/_config/collections.js';
|
import {getAllPosts, showInSitemap, tagList, goPages} from './src/_config/collections.js';
|
||||||
import events from './src/_config/events.js';
|
import events from './src/_config/events.js';
|
||||||
import filters from './src/_config/filters.js';
|
import filters from './src/_config/filters.js';
|
||||||
import plugins from './src/_config/plugins.js';
|
import plugins from './src/_config/plugins.js';
|
||||||
|
|
@ -42,6 +42,7 @@ export default async function (eleventyConfig) {
|
||||||
eleventyConfig.addCollection('allPosts', getAllPosts);
|
eleventyConfig.addCollection('allPosts', getAllPosts);
|
||||||
eleventyConfig.addCollection('showInSitemap', showInSitemap);
|
eleventyConfig.addCollection('showInSitemap', showInSitemap);
|
||||||
eleventyConfig.addCollection('tagList', tagList);
|
eleventyConfig.addCollection('tagList', tagList);
|
||||||
|
eleventyConfig.addCollection('goPages', goPages);
|
||||||
|
|
||||||
// --------------------- Plugins
|
// --------------------- Plugins
|
||||||
eleventyConfig.addPlugin(plugins.htmlConfig);
|
eleventyConfig.addPlugin(plugins.htmlConfig);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,34 @@ export const tagList = collection => {
|
||||||
const tagsSet = new Set();
|
const tagsSet = new Set();
|
||||||
collection.getAll().forEach(item => {
|
collection.getAll().forEach(item => {
|
||||||
if (!item.data.tags) return;
|
if (!item.data.tags) return;
|
||||||
item.data.tags.filter(tag => !['posts', 'docs', 'all'].includes(tag)).forEach(tag => tagsSet.add(tag));
|
item.data.tags.filter(tag => !['posts', 'docs', 'all', 'mix', 'project'].includes(tag)).forEach(tag => tagsSet.add(tag));
|
||||||
});
|
});
|
||||||
return Array.from(tagsSet).sort();
|
return Array.from(tagsSet).sort();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** goPage URLs. these are defined within a page's Markdown frontmatter as 'go:', and are output as _redirects. the webserver can read this file and redirect users who navigate directly to URL defined in this collection, they will be redirected to the page. **/
|
||||||
|
export const goPages = collectionApi => {
|
||||||
|
return collectionApi.getAll().filter(p => p.data.go);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** All tracks, grouped by project and sorted */
|
||||||
|
export const tracksByProject = collectionApi => {
|
||||||
|
const tracks = {};
|
||||||
|
// Get all pages that have a track_number
|
||||||
|
collectionApi.getAll()
|
||||||
|
.filter(item => item.data.track_number !== undefined)
|
||||||
|
.forEach(item => {
|
||||||
|
const project = item.data.project;
|
||||||
|
if (!tracks[project]) {
|
||||||
|
tracks[project] = [];
|
||||||
|
}
|
||||||
|
tracks[project].push(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Sort tracks within each project
|
||||||
|
for (const project in tracks) {
|
||||||
|
tracks[project].sort((a, b) => a.data.track_number - b.data.track_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tracks;
|
||||||
|
};
|
||||||
14
src/_includes/partials/card-mix-track.njk
Normal file
14
src/_includes/partials/card-mix-track.njk
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{% set headingLevel = headingLevel | default("h2") %}
|
||||||
|
{% set definedDate = definedDate | default(item.date) %}
|
||||||
|
|
||||||
|
<custom-card no-padding>
|
||||||
|
<{{ headingLevel }} slot="headline" class="text-step-2">
|
||||||
|
<a href="{{ item.url | url }}">{{ item.data.title }}</a>
|
||||||
|
</{{ headingLevel }}>
|
||||||
|
<span slot="date">{%- if item.data.draft -%}<span class="button" data-small-button data-button-variant='tertiary'>draft</span>{%- endif %} {% include "partials/date.njk" %}</span>
|
||||||
|
<div slot="content" webc:nokeep>{{ item.data.description | markdownFormat | safe }}</div>
|
||||||
|
</custom-card>
|
||||||
|
|
||||||
|
{% css "local" %}
|
||||||
|
{% include "css/custom-card.css" %}
|
||||||
|
{% endcss %}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<hr />
|
<hr />
|
||||||
<p class="text-step-min-1">
|
<p class="text-step-min-1">
|
||||||
{{ meta[page.lang].blog.githubEdit }}
|
{{ meta[page.lang].blog.githubEdit }}
|
||||||
<a href="{{ pkg.repository.url | url | replace('.git', '/branch/main/') }}{{ page.inputPath }}"
|
<a href="{{ pkg.repository.url | replace('.git', '') }}/src/branch/main/{{ page.inputPath | replace('./', '') }}"
|
||||||
>{{ meta.viewRepo.infoText }}</a
|
>{{ meta.viewRepo.infoText }}</a
|
||||||
>.
|
>.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
20
src/_layouts/mix.njk
Normal file
20
src/_layouts/mix.njk
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
layout: base
|
||||||
|
---
|
||||||
|
|
||||||
|
<div class="region" style="--region-space-top: var(--space-xl-2xl)">
|
||||||
|
<div class="wrapper flow prose">
|
||||||
|
<h1 class="gradient-text">{{ title }}</h1>
|
||||||
|
{{ content | safe }}
|
||||||
|
|
||||||
|
<h2>Tracks</h2>
|
||||||
|
<div class="feature | region region-space-l">
|
||||||
|
<custom-masonry layout="50-50">
|
||||||
|
{% set projectTracks = collections.tracksByProject[project] %}
|
||||||
|
{% for track in projectTracks %}
|
||||||
|
{% include "partials/card-mix-track.njk" %}
|
||||||
|
{% endfor %}
|
||||||
|
</custom-masonry>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -9,4 +9,9 @@ excludeFromSitemap: true
|
||||||
{{ oldUrl }} {{ page.url }}
|
{{ oldUrl }} {{ page.url }}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
|
||||||
|
|
||||||
|
{% for page in collections.goPages %}
|
||||||
|
/go/{{ page.data.go }} {{ page.url }}
|
||||||
|
{% endfor %}
|
||||||
12
src/pages/projects/mixes/tomorrowsbacon/01-track-one.md
Normal file
12
src/pages/projects/mixes/tomorrowsbacon/01-track-one.md
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
title: "Greenpeace"
|
||||||
|
artist: "James"
|
||||||
|
date: 2001-01-01
|
||||||
|
project: TomorrowsBacon
|
||||||
|
track_number: 1
|
||||||
|
---
|
||||||
|
## Notes
|
||||||
|
Notes go here.
|
||||||
|
|
||||||
|
## Lyrics
|
||||||
|
Lyrics go here.
|
||||||
7
src/pages/projects/mixes/tomorrowsbacon/index.md
Normal file
7
src/pages/projects/mixes/tomorrowsbacon/index.md
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
layout: mix
|
||||||
|
title: "Tomorrow's Bacon"
|
||||||
|
project: TomorrowsBacon
|
||||||
|
permalink: /mixes/tomorrowsbacon/index.html
|
||||||
|
---
|
||||||
|
Nothing goes here.
|
||||||
Loading…
Reference in a new issue