Quellcode durchsuchen

:sparkles: repacking material list with inbetweens

tags/0.9.0
J vor 4 Jahren
Ursprung
Commit
7fe5843db0
1 geänderte Dateien mit 20 neuen und 2 gelöschten Zeilen
  1. 20
    2
      vue-theme/src/store/modules/artist.js

+ 20
- 2
vue-theme/src/store/modules/artist.js Datei anzeigen

@@ -17,6 +17,20 @@ const getters = {
17 17
     allArtistsLoaded: state => state.loaded,
18 18
 }
19 19
 
20
+const _insertInbetweens = posts => {
21
+    // const posts = [
22
+    //     { name: "cedar", count: 2 },
23
+    //     { name: "fir", count: 6 },
24
+    //     { name: "pine", count: 3 }
25
+    // ];
26
+
27
+    // suppose we need to skip the first element
28
+    const result = posts.find((tree, i) => {
29
+        if (tree.count > 1 && i !== 0) return true;
30
+    });
31
+    // { name: "fir", count: 6 }
32
+}
33
+
20 34
 const _arrangeByMaterial = artistsList => {
21 35
     const byMaterial = {}
22 36
     artistsList.forEach(artist => {
@@ -25,8 +39,12 @@ const _arrangeByMaterial = artistsList => {
25 39
             byMaterial[mat].push(artist)
26 40
         })
27 41
     })
28
-    console.log(byMaterial)
29
-    return Object.values(byMaterial).flat()
42
+    const flatPacked = []
43
+    Object.keys(byMaterial).forEach(material => {
44
+        flatPacked.push({ slug: material, title: material })
45
+        byMaterial[material].forEach(artist => flatPacked.push(artist))
46
+    })
47
+    return flatPacked
30 48
 }
31 49
 
32 50
 const actions = {

Laden…
Abbrechen
Speichern