import 'dart:html' show HttpRequest, Element, querySelector; final excluded_keywords = {'index', 'CONTRIBUTING', 'LICENSE', 'README'}; // Get the sitemap content Future fetchRemoteSitemap() 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 t_sitemap, [String? t_prefix, Map? t_links]) { t_links ??= {}; // parse each element in sitemap for (var elem in t_sitemap) { // if it’s a link if (elem.innerHtml!.startsWith('> parseSitemap() async { final content = await fetchRemoteSitemap(); final sitemap = Element.ul()..innerHtml = content; final sitemapNodes = sitemap.querySelector('ul')!.children; return detectPages(sitemapNodes); } Future createSitemap() async { final sitemap = await parseSitemap(); final pages = querySelector('#drop-page')!; sitemap.forEach((url, name) { final link = Element.li() ..classes.add('dropdown-item') ..append(Element.a() ..attributes['href'] = url ..innerText = name); pages.append(link); }); }