import 'dart:html' show HttpRequest;
import 'package:html/parser.dart' show parse;
import 'package:html/dom.dart' show Element;
final excluded_keywords = ['index', 'CONTRIBUTING', 'LICENSE', 'README'];
// Get the sitemap content
Future getSitemap() async {
const path = 'sitemap.html';
try {
return await HttpRequest.getString(path);
} catch (e) {
print('Couldn’t open $path');
}
return 'Error';
}
// Parse the list of elements and detect pages from this list
Map detectPages(List sitemap, [String prefix]) {
final links = {};
for (var elem in sitemap) {
for(var kw in excluded_keywords) {
if (elem.outerHtml.contains(kw)) {
continue;
}
}
if (elem.innerHtml.startsWith('> parseSitemap() async {
final content = await getSitemap();
final sitemap = parse(content).getElementsByClassName('org-ul')[0].children;
return detectPages(sitemap);
}