Skip to content

Commit

Permalink
languages and link fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-92 committed Jan 12, 2025
1 parent 0062813 commit e51d923
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const params = new URLSearchParams(document.location.search);
if (params.has("path")) {
let path = params.get("path");
if (parames.has("lang")) {
let lang = params.get("lang");
} else {
let lang = "en";
}
// Get HTML and metadata for article on English Wikipedia
let base = "https://api.wikimedia.org/core/v1/wikipedia/en/page/";
let url = base + path + "/with_html";
let base = "https://api.wikimedia.org/core/v1/wikipedia/";
let url = base + lang + "/page/" + path + "/with_html";
fetch(url)
.then((res) => {
return res.json();
Expand All @@ -15,6 +20,9 @@ if (params.has("path")) {
document.getElementById("content").innerHTML = res.html;
document.getElementById("title").innerText = res.title;
console.log(res);
document.querySelectorAll('[href*="wikipedia.org"]').forEach((link) => {
link.href = link.href.replace("wikipedia.org", "credipedia.org");
});
})
.catch(console.error);
}

0 comments on commit e51d923

Please sign in to comment.