get_date = ({ article, project = "en.wikipedia.org" }) => {
const query =
`SELECT ?item ?itemLabel ?date
WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "` +
project +
`";
wikibase:api "Generator";
mwapi:generator "links";
mwapi:titles "` +
article +
`";.
?item wikibase:apiOutputItem mwapi:item.
}
FILTER BOUND (?item)
?item wdt:P585 ?date .
?item rdfs:label ?itemLabel filter (lang(?itemLabel) = "en") .
}
ORDER BY DESC(?date)`;
return fetch(
`https://query.wikidata.org/sparql?query=${encodeURIComponent(query)}`,
{ headers: { accept: "application/sparql-results+json" } }
)
.then((response) => response.json())
.then((d) =>
d.results.bindings.map((res) => ({
item: res.item.value,
itemLabel: res.itemLabel.value,
date: d3.utcParse("%Y-%m-%dT%H:%M:%SZ")(res.date.value)
}))
);
}