frontend: Normalize tags
This commit is contained in:
parent
42b9e54ec7
commit
eaca60e5e0
3 changed files with 4 additions and 3 deletions
|
@ -29,8 +29,8 @@
|
||||||
bind:value={filter}
|
bind:value={filter}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
{#each Object.keys($tags).sort(function (a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); }) as itag, index}
|
{#each Object.keys($tags).sort(function (a, b) { return a.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().localeCompare(b.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase()); }) as itag, index}
|
||||||
{#if (filter === "" && $tags[itag].count > 1) || (filter !== "" && itag.toLowerCase().indexOf(filter.toLowerCase()) >= 0)}
|
{#if (filter === "" && $tags[itag].count > 1) || (filter !== "" && itag.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().indexOf(filter.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase()) >= 0)}
|
||||||
<DropdownItem href="tags/{itag}">
|
<DropdownItem href="tags/{itag}">
|
||||||
#{itag}
|
#{itag}
|
||||||
<Badge>
|
<Badge>
|
||||||
|
|
|
@ -59,6 +59,7 @@ export const tags = derived([my, themesStore], ([$my, $themesStore]) => {
|
||||||
for (const key in $themesStore) {
|
for (const key in $themesStore) {
|
||||||
for (const exercice of $themesStore[key].exercices) {
|
for (const exercice of $themesStore[key].exercices) {
|
||||||
exercice.tags.forEach((tag) => {
|
exercice.tags.forEach((tag) => {
|
||||||
|
tag = tag.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
||||||
if (!tags[tag])
|
if (!tags[tag])
|
||||||
tags[tag] = {count: 1, solved: 0};
|
tags[tag] = {count: 1, solved: 0};
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
for (let k in $themes) {
|
for (let k in $themes) {
|
||||||
const th = $themes[k];
|
const th = $themes[k];
|
||||||
for (const ex of th.exercices) {
|
for (const ex of th.exercices) {
|
||||||
if (ex.tags.indexOf(data.tag) >= 0) {
|
if (ex.tags.map(t => t.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase()).indexOf(data.tag.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase()) >= 0) {
|
||||||
tmp_exercices.push({theme: th, exercice: ex, index: k + "," + ex.id});
|
tmp_exercices.push({theme: th, exercice: ex, index: k + "," + ex.id});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue