fix: don't mutate shuffled arrays
This commit is contained in:
parent
a15a472721
commit
ff3f538171
4 changed files with 10 additions and 9 deletions
|
@ -1,11 +1,12 @@
|
|||
export const shuffleArray = array => {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const shuffled = [...array]
|
||||
for (let i = shuffled.length - 1; i > 0; i--) {
|
||||
let j = Math.floor(Math.random() * (i + 1))
|
||||
let temp = array[i]
|
||||
array[i] = array[j]
|
||||
array[j] = temp
|
||||
let temp = shuffled[i]
|
||||
shuffled[i] = shuffled[j]
|
||||
shuffled[j] = temp
|
||||
}
|
||||
return array
|
||||
return shuffled
|
||||
}
|
||||
|
||||
export const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
|
||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "coryd.dev",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@cdransf/api-text": "^1.5.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
@ -6,7 +6,7 @@ permalink: "/watching/index.html"
|
|||
updated: "now"
|
||||
schema: watching
|
||||
---
|
||||
{% assign featuredMovie = movies.recentlyWatched | shuffleArray | first %}
|
||||
{%- assign featuredMovie = movies.recentlyWatched | shuffleArray | first -%}
|
||||
<h2 class="watching">{{ title }}</h2>
|
||||
{% render "partials/media/watching/hero.liquid" movie:featuredMovie %}
|
||||
<p>Here's all of the TV and movies I've been watching presented in what is (hopefully) an organized fashion.</p>
|
||||
|
|
Reference in a new issue