diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 00000000..fa1b674b --- /dev/null +++ b/deploy.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +function buildGHPages { + npm run build +} + +set -e # Exit with nonzero exit code if anything fails + +SOURCE_BRANCH="master" +TARGET_BRANCH="gh-pages" +MINE="git@github.com:rwaldron/tc39-notes.git"; +TC39="git@github.com:tc39/tc39-notes.git"; +SHA=`git rev-parse --verify HEAD` + +# Checkout "gh-pages" +git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH + +# Reset +git reset --hard + +# Merge master for latest content +git merge $SOURCE_BRANCH + +# Build it! +buildGHPages + +# Commit the build +git add --all . +git commit -m "Build: ${SHA}" + +# Push updates to: +# rwaldron/tc39-notes#gh-pages +git push $MINE $TARGET_BRANCH -f +# tc39/tc39-notes#gh-pages +git push $TC39 $TARGET_BRANCH -f + + +# When done, gtfo. +git checkout $SOURCE_BRANCH diff --git a/package.json b/package.json new file mode 100644 index 00000000..a43d8efa --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "tc39-notes", + "version": "1.0.0", + "description": "These are the notes that I've taken since joining TC39 as a representative of the jQuery Foundation.", + "main": "index.js", + "scripts": { + "build": "./scripts/builder.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rwaldron/tc39-notes.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/rwaldron/tc39-notes/issues" + }, + "homepage": "https://github.com/rwaldron/tc39-notes#readme", + "devDependencies": { + "common-tags": "^1.4.0", + "glob": "^7.1.2", + "remarkable": "^1.7.1" + } +} diff --git a/scripts/builder.js b/scripts/builder.js new file mode 100755 index 00000000..8a7242ce --- /dev/null +++ b/scripts/builder.js @@ -0,0 +1,76 @@ +#!/usr/bin/env node + +// System objects +const fs = require("fs"); +const cp = require("child_process"); +const path = require("path"); + +// Third party objects +const ct = require("common-tags"); +const glob = require("glob"); +const Remarkable = require("remarkable"); + +// Program instances +const remarkable = new Remarkable({ + html: true, + linkify: true, +}); + + +glob("./es*/**/*.md", (error, results) => { + const aliases = {}; + const titles = {}; + const links = []; + const contents = results.reverse().reduce((accum, file) => { + const source = fs.readFileSync(file, "utf8"); + const name = file.replace(/\.\/es.\//, ""); + aliases[name] = name.replace(/(\d{4}-\d{2})\//, "$1_").replace(".md", ".html"); + titles[name] = source.split('\n')[0].replace("# ", "").trim(); + accum[name] = source; + return accum; + }, {}); + + + // console.log(index(Object.keys(contents))); +// console.log(titles); + // console.log(aliases); + + // console.log(contents["2017-05/may-25.md"]); + + Object.keys(aliases).forEach(alias => { + const fileName = aliases[alias]; + const title = titles[alias]; + const content = contents[alias]; + fs.writeFileSync(fileName, makePage({ title, content })); + + // links.push(remarkable.render(`[${title.replace(" Meeting Notes", "")}](${fileName})`)); + links.push(`- [${title.replace(" Meeting Notes", "")}](${fileName})`); + }); + + + const index = makeIndex({ links }); + + fs.writeFileSync("index.html", index); +}); + + +function makeIndex({links}) { + return ct.stripIndent` + + +