From 5f5079ddfe8691614fd779c4536248ba08f97827 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sun, 10 Oct 2021 23:50:50 +0200 Subject: [PATCH] Fix link to lexemes, fix #507 --- Logic/Web/Wikidata.ts | 9 +++++++++ UI/Wikipedia/WikidataPreviewBox.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Logic/Web/Wikidata.ts b/Logic/Web/Wikidata.ts index c23a5347c..4c9fd5081 100644 --- a/Logic/Web/Wikidata.ts +++ b/Logic/Web/Wikidata.ts @@ -273,6 +273,15 @@ export default class Wikidata { return undefined; } + public static IdToArticle(id: string){ + if(id.startsWith("Q")){ + return "https://wikidata.org/wiki/"+id + } + if(id.startsWith("L")){ + return "https://wikidata.org/wiki/Lexeme:"+id + } + throw "Unknown id type: "+id + } /** * Loads a wikidata page diff --git a/UI/Wikipedia/WikidataPreviewBox.ts b/UI/Wikipedia/WikidataPreviewBox.ts index 3fe01aab8..d6682326b 100644 --- a/UI/Wikipedia/WikidataPreviewBox.ts +++ b/UI/Wikipedia/WikidataPreviewBox.ts @@ -51,7 +51,7 @@ export default class WikidataPreviewBox extends VariableUiElement { wikidata.id, Svg.wikidata_ui().SetStyle("width: 2.5rem").SetClass("block") ]).SetClass("flex"), - "https://wikidata.org/wiki/"+wikidata.id ,true).SetClass("must-link") + Wikidata.IdToArticle(wikidata.id) ,true).SetClass("must-link") console.log(wikidata) let info = new Combine( [