Skip to content

Commit 2f3b89b

Browse files
committed
⚡ Include the index in item ID
1 parent 7f555ee commit 2f3b89b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/components/LinkItems/Section.vue

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
:style="gridStyle"
1818
>
1919
<Item
20-
v-for="(item) in sortedItems"
21-
:id="makeId(title, item.title)"
22-
:key="makeId(title, item.title)"
20+
v-for="(item, index) in sortedItems"
21+
:id="makeId(title, item.title, index)"
22+
:key="makeId(title, item.title, index)"
2323
:url="item.url"
2424
:title="item.title"
2525
:description="item.description"
@@ -114,9 +114,10 @@ export default {
114114
},
115115
methods: {
116116
/* Returns a unique lowercase string, based on name, for section ID */
117-
makeId(sectionStr, itemStr) {
117+
makeId(sectionStr, itemStr, index) {
118118
const charSum = sectionStr.split('').map((a) => a.charCodeAt(0)).reduce((x, y) => x + y);
119-
return `${charSum}_${itemStr.replace(/\s+/g, '-').replace(/[^a-zA-Z ]/g, '').toLowerCase()}`;
119+
const itemTitleStr = itemStr.replace(/\s+/g, '-').replace(/[^a-zA-Z ]/g, '').toLowerCase();
120+
return `${index}_${charSum}_${itemTitleStr}`;
120121
},
121122
/* Opens the iframe modal */
122123
triggerModal(url) {

0 commit comments

Comments
 (0)