mirror of
https://github.com/veggiemonk/awesome-docker.git
synced 2024-10-01 01:36:03 -04:00
Add id to each link
This commit is contained in:
parent
6656c3dc3b
commit
a321d2c048
16
build.js
16
build.js
@ -2,6 +2,7 @@ const fs = require('fs');
|
||||
const showdown = require('showdown');
|
||||
const cheerio = require('cheerio');
|
||||
const Parcel = require('parcel-bundler');
|
||||
const camelCase = require('camelcase');
|
||||
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
@ -47,7 +48,20 @@ const includeReadme = ({
|
||||
console.log('Merging files...');
|
||||
const $ = cheerio.load(indexTemplate);
|
||||
$('#md').append(converter.makeHtml(markdown));
|
||||
|
||||
$('a').each((i, elem) => {
|
||||
// console.log(elem);
|
||||
$(elem).attr(
|
||||
'id',
|
||||
`${camelCase(
|
||||
$(elem)
|
||||
.attr('href')
|
||||
.replace(/\/|\.|:|#/g, ''),
|
||||
{
|
||||
pascalCase: true,
|
||||
},
|
||||
)}-${i}`,
|
||||
);
|
||||
});
|
||||
console.log('Writing index.html');
|
||||
fs.writeFileSync(dest, $.html(), 'utf8');
|
||||
console.log('DONE 👍');
|
||||
|
@ -19,6 +19,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/veggiemonk/awesome-docker#readme",
|
||||
"dependencies": {
|
||||
"camelcase": "^5.0.0",
|
||||
"cheerio": "^1.0.0-rc.2",
|
||||
"critical": "^1.1.1",
|
||||
"parcel-bundler": "^1.6.2",
|
||||
|
Loading…
Reference in New Issue
Block a user