mirror of
https://github.com/veggiemonk/awesome-docker.git
synced 2025-01-03 03:31:18 -05: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 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';
|
||||||
|
|
||||||
@ -47,7 +48,20 @@ 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) => {
|
||||||
|
// console.log(elem);
|
||||||
|
$(elem).attr(
|
||||||
|
'id',
|
||||||
|
`${camelCase(
|
||||||
|
$(elem)
|
||||||
|
.attr('href')
|
||||||
|
.replace(/\/|\.|:|#/g, ''),
|
||||||
|
{
|
||||||
|
pascalCase: true,
|
||||||
|
},
|
||||||
|
)}-${i}`,
|
||||||
|
);
|
||||||
|
});
|
||||||
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 👍');
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
},
|
},
|
||||||
"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.1.1",
|
"critical": "^1.1.1",
|
||||||
"parcel-bundler": "^1.6.2",
|
"parcel-bundler": "^1.6.2",
|
||||||
|
Loading…
Reference in New Issue
Block a user