Skip to content

Commit 66e621e

Browse files
committed
decodeURIComponent
1 parent b5f0bbf commit 66e621e

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/components/Markdown.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
return `<a class="external" target="_blank" href="${href}" title="${text}">${text}</a>`;
2020
} else {
2121
// let uniqueId = newUniqueId();
22-
let uniqueId = href; //.split('/')[1];
23-
return `<a class="node-highlite" unique-id="${uniqueId}" id="${href}"
24-
data-id="${href}" title="${text}">${text}
25-
<span class="symbol node" unique-id="${uniqueId}" data-id="item_${href}"
22+
let uniqueId = decodeURIComponent(href); //.split('/')[1];
23+
return `<a class="node-highlite" unique-id="${uniqueId}" id="${decodeURIComponent(href)}"
24+
data-id="${decodeURIComponent(href)}" title="${text}">${text}
25+
<span class="symbol node" unique-id="${uniqueId}" data-id="item_${decodeURIComponent(href)}"
2626
data-class="${items
2727
.filter((d) => d.label == text)
2828
.map((d) => {

src/utils.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function extractLinks(markdown, mdData) {
1111
continue;
1212
} else {
1313
const label = match[3];
14-
const url = match[2];
14+
const url = decodeURIComponent(match[2]);
1515
// const id = url.split("/")[1] || url.split("/")[0];
1616
// console.log(label, id, url)
1717

@@ -27,14 +27,13 @@ export async function extractLinks(markdown, mdData) {
2727

2828
const allUrls = links.filter(link => link.url).map(link => link.id);
2929

30-
3130
let parseItems = [
3231
...getItemsFromDbById(allUrls, mdData, 'items'),
3332
];
3433

3534

36-
3735
for (let i = 0; i < links.length; i++) {
36+
3837
const link = links.find(d => parseItems[i]?.["@id"].includes(d.id));
3938
const json = parseItems[i];
4039
if (link) {
@@ -49,11 +48,13 @@ export async function extractLinks(markdown, mdData) {
4948
function getItemsFromDbById(ids, mdData, type) {
5049
const baseApiUrl = config.api;
5150

51+
5252
return mdData.filter(item => {
53-
const id = item["@id"];
53+
const id = (item["@id"]);
5454
// const idWithoutBaseUrl = id?.split('/').pop();
55+
return ids.find((d) => d == id)
5556

56-
return ids.includes(id);
57+
// return ids.includes(id);
5758
}).map(item => {
5859
// only for omeka
5960
item["@id"] = item["@id"]?.replace(/\/items\//, '/resources/')?.replace(/\/media\//, '/resources/')?.replace(/\/item_sets\//, '/resources/');

0 commit comments

Comments
 (0)