Sha256: 8296ce46d26a20e1978eb6a4aa498b78b664da71151dbea5f94119d350a5ce3f

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

---
   # Jekyll page that redirects to a random page, post or document
   # https://github.com/jekylltools/jekyll-random-redirect
   # v1.6
   permalink: /wiki:random
---

{%- assign docs = site.posts -%}

{%- if site.random_redirect.pages == true -%}
  {%- assign pages = site.wiki | where_exp:"page","page.url != '/random/'" -%}
  {%- assign docs = docs | concat: pages -%}
{%- endif -%}

{%- if site.random_redirect.documents == true -%}
  {%- assign docs = docs | concat: site.documents | uniq -%}
{%- endif -%}

   <script type="text/javascript">
      var urls=[];

      {% for doc in docs -%}
         urls.push("{{ doc.url | absolute_url }}");
      {% endfor -%}

      var url = urls[Math.floor(Math.random()*urls.length)];
      var link = document.createElement('link');
      link.setAttribute('rel', 'canonical');
      link.setAttribute('href', url);
      document.head.appendChild(link);

      if (typeof IE_fix != "undefined") {
         document.write("Redirecting...");
         var referLink = document.createElement("a");
         referLink.href = url;
         document.body.appendChild(referLink);
         referLink.click();
      } else {
         window.location.replace(url);
      }
   </script>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-theme-paperwiki-0.1.3 _pages/wiki/wiki_random.md