Skip to content

Conversation

@arkhi
Copy link
Member

@arkhi arkhi commented Nov 11, 2025

@alifeee made a proposal in a previous PR.

This is a different approach using structured data instead of HTML:

  1. Each participant has their own space to add data: the Toml file.
  2. The data is massaged to fit our use.

This PR does not touch master for now.


Things in this PR:

  • Add .editorconfig.
  • Add linters for JS and Toml files.
  • Use Eleventy.
  • Add basic nunjucks templates, based on existing files.
  • Structure data in toml files.
  • Fix data consistency.
  • Tag or remove obvious spam (Still quite a few to check in my opinion).
  • Create Github Actions to deploy on staging for now.
  • Remove github pages-related files.
  • Update link to create an entry.
  • Update README.md.

Some URL might lead to spam right now, but might have been totally legit websites at the time of submission. This is why some websites were not always removed.

Closes #160 #166.

From HTML to Toml files.

I used the following template and globalData to generate Toml files:

---
pagination:
  data: tomlFromLegacyHTML
  size: 1
  alias: participant
permalink: _exports/{{ participant | replace("/", "") | escape }}.toml
eleventyAllowMissingExtension: true
---
display = "{{ tomlFromLegacyHTML[participant].display | safe }}"

# Websites
# ------------------------------------------------------------------------------
{% for website in tomlFromLegacyHTML[participant].websites %}
[[websites]]
url   = "{{ website.url }}"
title = "{{ website.title }}"
years = [{{ website.years }}]
{% endfor %}
  // Create Toml files based on legacy HTML files.
  // TODO: Tweaked files to restore mistakes.
  eleventyConfig.addGlobalData("tomlFromLegacyHTML", () => {
    // Comment next line to create toml files based on existing HTML files.
    // Files can be found in _site/exports/participants/.
    return {};

    const files = fs.readdirSync(`./_assets/legacy-html-files/`);
    const participants = {};
    const findWebsite = (websites, url) => websites.find(website => website.url === url);

    for (const file of files) {
      const content = fs.readFileSync(
        `./_assets/legacy-html-files/${file}`, 'utf8'
      );

      const listContent = /            <li>(?<inner>.*)<\/li>/g;
      const listItems = [...content.matchAll(listContent)];

      listItems.forEach((item, index) => {
        // SEE https://regex101.com/r/g4rGk7
        // TODO Improve grouping?
        const groups = [...item.groups.inner.matchAll(/(?<prefix>.*?)[\W+]*((<a.+?href="(?<url>[^"]+)">(?<title>.+?)<\/a>)[\W+]*?)/g)];

        // Set default values for slug.
        let participantID = groups[0]?.groups?.prefix?.trim();
        let title = groups[0]?.groups?.title?.trim();

        groups.forEach(group => {
          const url = group.groups.url;
          const currentYear = file.replace('.html', '');

          // Slugify potential id, with fallback in case of non-latin characters.
          const slug =
            `${eleventyConfig.getFilter("slugify")(participantID || title)}`
            || `${title}-${index}`;

          title = group.groups.title;

          // Create entry if not already present.
          if (!participants[slug]) {
            participants[slug] = {
              display: participantID || title,
              websites: [],
            };
          }

          // Add website to existing entries.
          if (!findWebsite(participants[slug].websites, url)) {
            participants[slug].websites.push({
              url: url,
              title: title || participantID,
              years: [currentYear],
            });
          } else {
            if (!findWebsite(participants[slug].websites, url).years.find(year => year === currentYear)) {
              findWebsite(participants[slug].websites, url).years.push(
                currentYear
              );
            }
          }
        });
      });
    }

    return participants;
  });

alifeee and others added 30 commits May 10, 2024 00:02
* Allow the use of Toml formats.
* Add _Global Data Files_ as examples.
* Use nunjucks for templates.
* Move legacy files into separate folder.
* Tweak eleventy.config.js.
* Based on _Global Data Files_ participants, use `eleventyComputed` to provide another structure to templates.
* Based on _Global Data Files_ participants, use `before` in pagination to provide pagination by years.
@arkhi arkhi force-pushed the issues/160-refactor-eleventy branch 6 times, most recently from 1a20506 to e617de5 Compare November 11, 2025 13:54
@arkhi arkhi force-pushed the issues/160-refactor-eleventy branch from e617de5 to d86fc0f Compare November 11, 2025 14:04
@arkhi arkhi force-pushed the issues/160-refactor-eleventy branch from 4f02d4b to bdd398d Compare November 11, 2025 14:17
@arkhi arkhi marked this pull request as ready for review November 11, 2025 21:18
@arkhi arkhi requested a review from j9t November 11, 2025 21:19
@arkhi arkhi force-pushed the issues/160-refactor-eleventy branch from fe0aa2b to 7326b91 Compare November 11, 2025 23:32
It can not parse nunjucks template within the permalink.
@j9t
Copy link
Member

j9t commented Nov 12, 2025

I’m on the road for a few days—will try to review in between but can’t tell yet.

* Use array-like data to define what to get from the global data. This allows nunjucks filters.
* Add globals for first and current year.
* Add filters and clean config file a bit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants