Remove ids from links

This commit is contained in:
Julien Bisconti 2018-06-08 19:38:46 +02:00
parent aca9367c69
commit c306007594
2 changed files with 4 additions and 19 deletions

View File

@ -2,7 +2,6 @@ const fs = require('fs');
const showdown = require('showdown'); const showdown = require('showdown');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
const Parcel = require('parcel-bundler'); const Parcel = require('parcel-bundler');
const camelCase = require('camelcase');
process.env.NODE_ENV = 'production'; process.env.NODE_ENV = 'production';
@ -19,7 +18,7 @@ const includeReadme = ({
md = readme, md = readme,
templateHTML = template, templateHTML = template,
dest = merged, dest = merged,
}) => { } = {}) => {
const converter = new showdown.Converter({ const converter = new showdown.Converter({
omitExtraWLInCodeBlocks: true, omitExtraWLInCodeBlocks: true,
simplifiedAutoLink: true, simplifiedAutoLink: true,
@ -48,19 +47,6 @@ const includeReadme = ({
console.log('Merging files...'); console.log('Merging files...');
const $ = cheerio.load(indexTemplate); const $ = cheerio.load(indexTemplate);
$('#md').append(converter.makeHtml(markdown)); $('#md').append(converter.makeHtml(markdown));
$('a').each((i, elem) => {
$(elem).attr(
'id',
camelCase(
$(elem)
.attr('href')
.replace(/\/|\.|:|#/g, ''),
{
pascalCase: true,
},
),
);
});
console.log('Writing index.html'); console.log('Writing index.html');
fs.writeFileSync(dest, $.html(), 'utf8'); fs.writeFileSync(dest, $.html(), 'utf8');
console.log('DONE 👍'); console.log('DONE 👍');
@ -82,7 +68,7 @@ const bundle = (dest = destination) => {
}; };
const main = () => { const main = () => {
includeReadme({}); includeReadme();
bundle(); bundle();
}; };

View File

@ -1,7 +1,7 @@
{ {
"name": "awesome-docker-website", "name": "awesome-docker-website",
"version": "1.0.0", "version": "1.0.0",
"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)**.", "description": "A curated list of Docker resources and projects Inspired by @sindresorhus and improved by amazing contributors",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "rimraf ./dist/ && node build.js", "build": "rimraf ./dist/ && node build.js",
@ -16,13 +16,12 @@
"url": "git+https://github.com/veggiemonk/awesome-docker.git" "url": "git+https://github.com/veggiemonk/awesome-docker.git"
}, },
"author": "Julien Bisconti <julien.bisconti at gmail dot com>", "author": "Julien Bisconti <julien.bisconti at gmail dot com>",
"license": "MIT", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/veggiemonk/awesome-docker/issues" "url": "https://github.com/veggiemonk/awesome-docker/issues"
}, },
"homepage": "https://github.com/veggiemonk/awesome-docker#readme", "homepage": "https://github.com/veggiemonk/awesome-docker#readme",
"dependencies": { "dependencies": {
"camelcase": "^5.0.0",
"cheerio": "^1.0.0-rc.2", "cheerio": "^1.0.0-rc.2",
"critical": "^1.3.2", "critical": "^1.3.2",
"dayjs": "^1.6.4", "dayjs": "^1.6.4",