forked from tc39/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rick Waldron <[email protected]>
- Loading branch information
Showing
3 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="[email protected]:rwaldron/tc39-notes.git"; | ||
TC39="[email protected]: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<ul> | ||
${remarkable.render(links.join('\n'))} | ||
</ul> | ||
`; | ||
} | ||
|
||
function makePage({title, content}) { | ||
return ct.stripIndent` | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>${title}</title> | ||
${remarkable.render(content)} | ||
`; | ||
} | ||
|
||
|