generate-examples-index-webpack-plugin
Version:
Generate an examples index page from your examples folder
17 lines (14 loc) • 374 B
JavaScript
const fs = require('fs');
/**
* Given an existing html file, return its title, if any
*
* @param file route of the file
* @returns title or empty string
*/
function getHtmlTitle(file) {
const regExp = /<title>(.*)<\/title>/;
const html = fs.readFileSync(file);
const match = regExp.exec(html);
return match && match[1] || '';
}
module.exports = getHtmlTitle;