Skip to content

Commit

Permalink
Add builds for eleventy
Browse files Browse the repository at this point in the history
Add eleventy to automatically build web pages
  • Loading branch information
tskarhed committed May 11, 2023
2 parents ddae962 + 2a3b1ed commit b79b235
Show file tree
Hide file tree
Showing 47 changed files with 3,014 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

module.exports = function(eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);

// Copy any .svg or midi file to `_site`, via Glob pattern
// Keeps the same directory structure
eleventyConfig.addPassthroughCopy("songs/**/*.svg");
eleventyConfig.addPassthroughCopy("songs/**/*.midi");
eleventyConfig.addPassthroughCopy("songs/styles.css");
};
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
*.toc
*.txt
*.ini
*.svg

_site
node_modules
.idea
/songs/**/*.md
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#93e6fc",
"activityBar.background": "#93e6fc",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#fa45d4",
"activityBarBadge.foreground": "#15202b",
"commandCenter.border": "#15202b99",
"sash.hoverBorder": "#93e6fc",
"statusBar.background": "#61dafb",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#2fcefa",
"statusBarItem.remoteBackground": "#61dafb",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#61dafb",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#61dafb99",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#61dafb"
}
5 changes: 5 additions & 0 deletions build-lilypond.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd songs

for dir in */; do
(cd $dir && lilypond --svg main.ly)
done
50 changes: 50 additions & 0 deletions generate_11ty_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const fs = require('fs');
const yaml = require('js-yaml');
const { globSync } = require('glob');

const songShortNames = fs.readdirSync('./songs', {
withFileTypes: true
}).reduce((totalArray, currentVal) => {
// Ignore meta directories
if(currentVal.name[0] == '_'){
return totalArray;
}

if(currentVal.isDirectory()){
totalArray.push(currentVal.name);
return totalArray;
}
return totalArray;
}, []);

songShortNames.forEach((shortName) => {

const yamlFile = globSync(`./songs/${shortName}/*.yaml`)[0];
if(!yamlFile){
return;
}
const metadata = yaml.load(fs.readFileSync(yamlFile));


const midiPaths = globSync(`./songs/${shortName}/*.midi`).reverse();


if(!midiPaths){
console.log(shortName, 'does not have any MIDI files');
}
metadata.midiFiles = midiPaths.map((path) => {
return path.substring(5); // Get path without '/songs'
});

const svgPaths = globSync(`./songs/${shortName}/*.svg`).reverse();
if(!svgPaths) {
console.log(shortName, 'does not have any SVG files');
}
metadata.svgFiles = svgPaths.map((path) => {
return path.substring(5); // Get path without '/songs'
});;

const meta = yaml.dump(metadata);
console.log(meta);
fs.writeFileSync(`./songs/${shortName}/index.md`, `---\n${meta}---`);
});
1 change: 0 additions & 1 deletion index.html

This file was deleted.

Loading

0 comments on commit b79b235

Please sign in to comment.