added layouts, some base content
This commit is contained in:
71
.eleventy.js
Normal file
71
.eleventy.js
Normal file
@@ -0,0 +1,71 @@
|
||||
const handlebarsPlugin = require("@11ty/eleventy-plugin-handlebars");
|
||||
const handlebars = require('handlebars');
|
||||
const sass = require("sass");
|
||||
const pluginRss = require("@11ty/eleventy-plugin-rss");
|
||||
|
||||
module.exports = function(eleventyConfig) {
|
||||
// Passthrough episodes directory to include both markdown and audio files
|
||||
eleventyConfig.addPassthroughCopy("episodes/*/*.mp3");
|
||||
eleventyConfig.addPlugin(handlebarsPlugin);
|
||||
eleventyConfig.addPlugin(pluginRss);
|
||||
|
||||
// handlebars helpers
|
||||
handlebars.registerHelper("formatSeasonEpisode", function(season, episode) {
|
||||
// Convert strings to integers and pad with zeros
|
||||
const seasonNumber = parseInt(season, 10).toString().padStart(2, '0');
|
||||
const episodeNumber = parseInt(episode, 10).toString().padStart(2, '0');
|
||||
|
||||
// Return the formatted string
|
||||
return `<span class="season">S${seasonNumber}</span><span class="episode">E${episodeNumber}</span>`;
|
||||
// return `S${seasonNumber}E${episodeNumber}`;
|
||||
});
|
||||
|
||||
eleventyConfig.addFilter("seasonEpisodeFormat", function (season, episode, separator="") {
|
||||
const seasonNumber = parseInt(season, 10).toString().padStart(2, '0');
|
||||
const episodeNumber = parseInt(episode, 10).toString().padStart(2, '0');
|
||||
return [seasonNumber, episodeNumber].join(separator)
|
||||
return value;
|
||||
});
|
||||
|
||||
handlebars.registerHelper('ifEquals', function(arg1, arg2, options) {
|
||||
return (arg1 == arg2) ? options.fn(this) : options.inverse(this);
|
||||
});
|
||||
|
||||
handlebars.registerHelper('ifIncludes', function(set, candidate, options) {
|
||||
return (set.includes(candidate)) ? options.fn(this) : options.inverse(this);
|
||||
});
|
||||
|
||||
// Creates the extension for use
|
||||
eleventyConfig.addTemplateFormats("scss");
|
||||
eleventyConfig.addExtension("scss", {
|
||||
outputFileExtension: "css", // optional, default: "html"
|
||||
|
||||
// `compile` is called once per .scss file in the input directory
|
||||
compile: async function (inputContent) {
|
||||
let result = sass.compileString(inputContent);
|
||||
|
||||
// This is the render function, `data` is the full data cascade
|
||||
return async (data) => {
|
||||
return result.css;
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
eleventyConfig.addNunjucksFilter("podcastUrl", function(post) {
|
||||
// Convert the season and episode to zero-padded numbers
|
||||
const seasonNumber = parseInt(post.data.season, 10).toString().padStart(2, '0');
|
||||
const episodeNumber = parseInt(post.data.episode, 10).toString().padStart(2, '0');
|
||||
|
||||
// Construct the podcast URL
|
||||
return `/episodes/s${seasonNumber}/s${seasonNumber}e${episodeNumber}.mp3`;
|
||||
});
|
||||
|
||||
return {
|
||||
dir: {
|
||||
data: "data",
|
||||
input: "content",
|
||||
output: "dist",
|
||||
includes: "../layouts"
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user