query-63940ceff20ac06cd714e11ef8c7bb85

rq turtle/ttl

rather than the sparql query (also not found/created yet) https://en.wikipedia.org/wiki/Template:Wikidata_sitelinkI am planning to display the article buttons using a template similar to this template but allowing custom QIDs: But I would need to add the query for the suggested existing article / translation source, and I have already succeeded in creating the query. Query 2 retrieves the suggested article

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?thecode ?thearticle WHERE {
  VALUES ?item {wd:Q1598293} .
  ?sitelink schema:name ?thearticle;
    schema:inLanguage ?thecode;
    schema:about wd:Q1598293.
  OPTIONAL {
    ?sitelink wikibase:badge ?badge.
    }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC (?badge)
LIMIT 1

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?badge") v2("?item"):::projected v3("?sitelink") v4("?thearticle"):::projected v5("?thecode"):::projected c7(["bd:serviceParam"]):::iri c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal c4(["wd:Q1598293"]):::iri bind0[/VALUES ?item/] bind0-->v2 bind00(["wd:Q1598293"]) bind00 --> bind0 v3 --"schema:name"--> v4 v3 --"schema:inLanguage"--> v5 v3 --"schema:about"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wikibase:badge".-> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end