diff --git a/.gitignore b/.gitignore index e50c4e7..a2e8584 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ node_modules .cache dist package-lock.json +website/index.merged.html +website/index.html diff --git a/README.md b/README.md index 2ab3aea..71d50b5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If this list is not complete, you can [contribute][editREADME] to make it so. He ***You can see the updates from [TWITTER](https://twitter.com/awesome_docker)*** -> **Please**, help organize these resources so that they are _easy to find_ and _understand_ for new comers. See how to **[Contribute](https://github.com/veggiemonk/awesome-docker/blob/master/CONTRIBUTING.md)** for tips! +> **Please**, help organize these resources so that they are _easy to find_ and _understand_ for new comers. See how to **[Contribute](https://github.com/veggiemonk/awesome-docker/blob/master/.github/CONTRIBUTING.md)** for tips! #### *If you see a link here that is not (any longer) a good fit, you can fix it by submitting a [pull request][editREADME] to improve this file. Thank you!* diff --git a/build.js b/build.js index 5b9f348..4dfb0fa 100644 --- a/build.js +++ b/build.js @@ -2,46 +2,75 @@ const fs = require('fs'); const showdown = require('showdown'); const cheerio = require('cheerio'); const Parcel = require('parcel-bundler'); +const critical = require('critical'); process.env.NODE_ENV = 'production'; -const converter = new showdown.Converter({ - omitExtraWLInCodeBlocks: true, - simplifiedAutoLink: true, - excludeTrailingPunctuationFromURLs: true, - literalMidWordUnderscores: true, - strikethrough: true, - tables: true, - tablesHeaderId: true, - ghCodeBlocks: true, - tasklists: true, - disableForced4SpacesIndentedSublists: true, - simpleLineBreaks: true, - requireSpaceBeforeHeadingText: true, - ghCompatibleHeaderId: true, - ghMentions: true, - backslashEscapesHTMLTags: true, - emoji: true, - splitAdjacentBlockquotes: true -}); -// converter.setFlavor('github'); +const main = () => { + const converter = new showdown.Converter({ + omitExtraWLInCodeBlocks: true, + simplifiedAutoLink: true, + excludeTrailingPunctuationFromURLs: true, + literalMidWordUnderscores: true, + strikethrough: true, + tables: true, + tablesHeaderId: true, + ghCodeBlocks: true, + tasklists: true, + disableForced4SpacesIndentedSublists: true, + simpleLineBreaks: true, + requireSpaceBeforeHeadingText: true, + ghCompatibleHeaderId: true, + ghMentions: true, + backslashEscapesHTMLTags: true, + emoji: true, + splitAdjacentBlockquotes: true + }); + // converter.setFlavor('github'); -console.log('Loading files...'); -const index = fs.readFileSync('index.tmpl', 'utf8'); -const readme = fs.readFileSync('README.md', 'utf8'); + console.log('Loading files...'); + const index = fs.readFileSync('website/index.tmpl.html', 'utf8'); + const readme = fs.readFileSync('README.md', 'utf8'); -console.log('Merging files...'); -const $ = cheerio.load(index); -$('#md').append(converter.makeHtml(readme)); + console.log('Merging files...'); + const $ = cheerio.load(index); + $('#md').append(converter.makeHtml(readme)); -console.log('Writing main.html'); -fs.writeFileSync('main.html', $.html(), 'utf8'); + console.log('Writing index.html'); + fs.writeFileSync('website/index.merged.html', $.html(), 'utf8'); -console.log('Bundling with Parcel.js'); -console.log(''); + console.log(''); + console.log('Generating critical css above the fold'); + console.log(''); -new Parcel('main.html', { - name: 'build', - // publicURL: '/awesome-docker' - publicURL: '/' -}).bundle(); + critical + .generate({ + inline: true, + base: 'website/', + src: 'index.merged.html', + dest: 'index.html', + css: 'website/style.css', + dimensions: [ + { + height: 200, + width: 500 + }, + { + height: 900, + width: 1200 + } + ] + }) + .then(() => { + console.log('Bundling with Parcel.js'); + console.log(''); + + new Parcel('website/index.html', { + name: 'build', + // publicURL: '/awesome-docker' + publicURL: '/' + }).bundle(); + }); +}; + +main(); diff --git a/index.html b/index.html index 572c816..d072a82 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,8 @@
We moved to a new place, click here to be redirected.
diff --git a/package.json b/package.json index 31da402..7ab651a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "> A curated list of Docker resources and projects Inspired by [@sindresorhus](https://github.com/sindresorhus)' [awesome][sindresorhus] and improved by these **[amazing contributors](https://github.com/veggiemonk/awesome-docker/graphs/contributors)**.", "main": "index.js", "scripts": { - "build": "node build.js", + "build": "rimraf ./dist/ && node build.js && rimraf ./website/index.html", "convert": "showdown makehtml -i README.md -o README.html --omitExtraWLInCodeBlocks --simplifiedAutoLink --excludeTrailingPunctuationFromURLs --literalMidWordUnderscores --strikethrough --tables --tablesHeaderId --ghCodeBlocks --tasklists --disableForced4SpacesIndentedSublists --simpleLineBreaks --requireSpaceBeforeHeadingText --ghCompatibleHeaderId --ghMentions --backslashEscapesHTMLTags --emoji --splitAdjacentBlockquotes", "package": "parcel build index.html --public-url /awesome-docker" }, @@ -20,8 +20,9 @@ "homepage": "https://github.com/veggiemonk/awesome-docker#readme", "dependencies": { "cheerio": "^1.0.0-rc.2", - "inline-assets": "^1.2.4", + "critical": "^1.1.1", "parcel-bundler": "^1.6.2", + "rimraf": "^2.6.2", "showdown": "^1.8.6" }, "devDependencies": { diff --git a/favicon.png b/website/favicon.png similarity index 100% rename from favicon.png rename to website/favicon.png diff --git a/index.js b/website/index.js similarity index 100% rename from index.js rename to website/index.js diff --git a/index.tmpl b/website/index.tmpl.html similarity index 75% rename from index.tmpl rename to website/index.tmpl.html index 8a6fb62..ae17cf4 100644 --- a/index.tmpl +++ b/website/index.tmpl.html @@ -1,4 +1,7 @@ - + + + + @@ -8,7 +11,7 @@ - + @@ -19,10 +22,13 @@ View on GitHub