Skip to content

Commit 9c94576

Browse files
committed
Add random snippet page
1 parent a8fbb91 commit 9c94576

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

builder/helpers/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ module.exports = {
7474
.toString('base64'))
7575
: '';
7676
},
77-
78-
7977
filterAndOrderForPresentation(snippets){
8078
const snippetsByPath = snippets.reduce((snippets, snippet)=>(snippets[snippet.path]=snippet, snippets), {});
8179
return [

builder/layouts/random.hbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
const values = [
3+
{{#each snippets}}
4+
'{{path}}',
5+
{{/each}}
6+
];
7+
8+
const path = values[Math.floor(Math.random() * values.length)];
9+
console.log(path);
10+
window.location = '/' + path.replace('.md', '/');
11+
</script>

snippets/pages/random.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
layout: random.hbs
3+
---

0 commit comments

Comments
 (0)