diff --git a/build.js b/build.js index 2e901b1..7a1ec10 100644 --- a/build.js +++ b/build.js @@ -2,6 +2,7 @@ const fs = require('fs'); const showdown = require('showdown'); const cheerio = require('cheerio'); const Parcel = require('parcel-bundler'); +const sm = require('sitemap'); process.env.NODE_ENV = 'production'; @@ -63,7 +64,29 @@ const bundle = (dest = destination) => { }) .bundle() .then(() => { - fs.copyFileSync('website/sitemap.xml', 'dist/sitemap.xml'); + // Creates a sitemap object given the input configuration with URLs + const sitemap = sm.createSitemap({ + hostname: 'https://awesome-docker.netlify.com/', + cacheTime: 6000000, // 600 sec (10 min) cache purge period + urls: [ + { + url: '/', + changefreq: 'daily', + priority: 0.8, + lastmodrealtime: true, + lastmodfile: 'dist/index.html', + }, + { + url: '/table.html', + changefreq: 'weekly', + priority: 0.8, + lastmodrealtime: true, + lastmodfile: 'dist/table.html', + }, + ], + }); + fs.writeFileSync('dist/sitemap.xml', sitemap.toString()); + // fs.copyFileSync('website/sitemap.xml', 'dist/sitemap.xml'); }); }; diff --git a/buildTable.js b/buildTable.js index e121039..ab86667 100644 --- a/buildTable.js +++ b/buildTable.js @@ -1,7 +1,6 @@ const fs = require('fs'); const cheerio = require('cheerio'); const dayjs = require('dayjs'); -const icons = require('./icons'); const getLatestFilename = fs.readFileSync('data/latest', 'utf-8'); console.log(getLatestFilename); @@ -38,6 +37,22 @@ const getLastUpdate = updated => { return updated; }; +const mapHomePage = h => { + if (h === 'manageiq.org') return 'https://manageiq.org'; + else if (h === 'dev-sec.io') return 'https://dev-sec.io'; + return h; +}; + +const mapLicense = l => { + if (l === 'GNU Lesser General Public License v3.0') return 'GNU LGPL v3.0'; + else if (l === 'GNU General Public License v2.0') return 'GNU GPL v2.0'; + else if (l === 'GNU General Public License v3.0') return 'GNU GPL v3.0'; + else if (l === 'BSD 3-Clause "New" or "Revised" License') + return 'BSD 3-Clause'; + else if (l === 'BSD 2-Clause "Simplified" License') return 'BSD 2-Clause'; + return l; +}; + const formatEntry = ( { name, @@ -62,19 +77,19 @@ const formatEntry = ( updated, )}
`, (homepage && - `🔗 website`) || + `website`) || '', ` `, - (language && - `${icons[language] || - '💻'}${language}
`) || - '', + (language && `💻${language}
`) || '', (license && - `📃 ${ - license.name - }`) || + license.url !== null && + `${mapLicense( + license.name, + )}`) || '', owner && `Made by
', - ); - - $('body').append( - [ - '', - ].join(''), - ); console.log('Writing table.html'); fs.writeFileSync(destination, $.html(), 'utf8'); console.log('DONE 👍'); diff --git a/icons.js b/icons.js deleted file mode 100644 index 9ed310b..0000000 --- a/icons.js +++ /dev/null @@ -1,40 +0,0 @@ -module.exports = { - C: - '', - Go: - '', - Ruby: - '', - CSS: - '', - 'C#': - '', - 'C++': - '', - Clojure: '', - 'Emacs Lisp': '', - Groovy: '', - Haskell: '', - HTML: - '', - Java: - '', - JavaScript: - '', - Lua: '', - Makefile: '', - Nginx: - '', - Perl: '', - PHP: - '', - Python: - '', - Roff: '', - Rust: '', - Scala: '', - Shell: '', - Vue: - '', - XSLT: '', -}; diff --git a/package.json b/package.json index 0dc2a23..aed2301 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,7 @@ "description": "A curated list of Docker resources and projects Inspired by @sindresorhus and improved by amazing contributors", "main": "index.js", "scripts": { - "build": "rimraf ./dist/ && node build.js", - "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", - "fetchdata": "node fetchRepos.js", - "table": "node buildTable.js" + "build": "node buildTable.js && rimraf ./dist/ && node build.js" }, "repository": { "type": "git", @@ -30,7 +26,8 @@ "node-fetch": "^2.1.2", "parcel-bundler": "^1.8.1", "rimraf": "^2.6.2", - "showdown": "^1.8.6" + "showdown": "^1.8.6", + "sitemap": "^1.13.0" }, "devDependencies": { "babel-eslint": "^8.2.3", @@ -40,6 +37,6 @@ "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-prettier": "^2.6.0", - "prettier": "^1.13.4" + "prettier": "^1.13.5" } } diff --git a/website/index.js b/website/index.js index c96e45f..ea2aabf 100644 --- a/website/index.js +++ b/website/index.js @@ -1,7 +1,19 @@ -const list = require('list.js'); +const List = require('list.js'); const main = () => { - console.log('hi!'); + const userList = new List('md', { + valueNames: [ + 'name', + 'description', + 'homepage', + 'star', + 'updated', + 'language', + 'license', + 'author', + ], + }); + console.log(`There are ${userList.size()} projects`); }; main(); diff --git a/website/index.tmpl.html b/website/index.tmpl.html index 776158f..3250935 100644 --- a/website/index.tmpl.html +++ b/website/index.tmpl.html @@ -195,6 +195,7 @@