<commit_before><!--
  Based on vue-futurelink with customisations for simplicity and performance
  REF: https://github.com/SamKnows/vue-futurelink
-->

<template>
<div class="dn" aria-hidden="true">
  <component :is="load"/>
</div>
</template>

<script>
import futurelink from 'futurelink';

export default {
  data: () => ({
    load: undefined,
    options: {
      links: [],
    },
  }),
  mounted() {
    // Don't run on the server
    if (typeof window === 'undefined') {
      return;
    }

    // Don't run on mobile
    if ('ontouchstart' in window) {
      return;
    }

    const loaded = [this.$route.path];

    this.options.future = (link) => {
      const href = link.getAttribute('href');

      if (loaded.includes(href)) {
        return;
      }

      loaded.push(href);

      // this.$emit('preload', href);

      const resolved = this.$router.resolve(href);
      const { matched } = resolved.resolved;
      this.load = matched[matched.length - 1].components.default;
    };

    futurelink(this.options);

    this.init();
    this.$router.afterEach(() => this.init());
  },
  methods: {
    init() {
      this.$nextTick(() => {
        const links = document.querySelectorAll('a[href^="/"');
        // Populate this.options.links {Array} from links {nodeList}
        for (let i = -1, l = links.length; ++i !== l; this.options.links[i] = links[i]); // eslint-disable-line no-plusplus
      });
    },
  },
};
</script><commit_msg>Futurelink minor improvements<commit_after><!--
  Based on vue-futurelink with customisations for simplicity and performance
  REF: https://github.com/SamKnows/vue-futurelink
-->

<template>
<div class="dn" aria-hidden="true">
  <component :is="load"/>
</div>
</template>

<script>
import futurelink from 'futurelink';

export default {
  data() {
    return {
      load: undefined,
      options: {
        links: [],
      },
    };
  },
  mounted() {
    // Don't run on the server
    if (typeof window === 'undefined') {
      return;
    }

    // Don't run on mobile
    if ('ontouchstart' in window) {
      return;
    }

    const loaded = [this.$route.path];

    this.options.future = (link) => {
      const href = link.getAttribute('href');

      if (loaded.includes(href)) {
        return;
      }

      loaded.push(href);

      // this.$emit('preload', href);

      const resolved = this.$router.resolve(href);
      const { matched } = resolved.resolved;
      this.load = matched[matched.length - 1].components.default;
    };

    futurelink(this.options);

    this.init();
    this.$router.afterEach(this.init);
  },
  methods: {
    init() {
      this.$nextTick(() => {
        const links = document.querySelectorAll('a[href^="/"');
        // Populate this.options.links {Array} from links {nodeList}
        for (let i = -1, l = links.length; ++i !== l; this.options.links[i] = links[i]); // eslint-disable-line no-plusplus
      });
    },
  },
};
</script>
{'fraction_non_alphanumeric': 0.17214503558115893, 'fraction_numerical': 0.0013554727211114877, 'mean_word_length': 2.4485981308411215, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4713386', 'n_tokens_mistral': 943, 'n_tokens_neox': 916, 'n_words': 209}