Skip to content

hunsalz/gridsome-source-wikidata

Repository files navigation

npm npm License

gridsome-source-wikidata

Install

  • yarn add gridsome-source-wikidata
  • npm install gridsome-source-wikidata

Usage

module.exports = {
  plugins: [
    {
      use: "gridsome-source-wikidata",
      options: {
        url: "https://query.wikidata.org/sparql",
        sparql: `SELECT DISTINCT ?item ?paintingLabel (MIN(?images) AS ?image) WHERE {
          ?painting (wdt:P31/(wdt:P279*)) wd:Q3305213;
            wdt:P170 wd:Q762;
            wdt:P18 ?images;
          BIND(REPLACE(STR(?painting), "^.*/", "") AS ?item)
          SERVICE wikibase:label {
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
            ?painting rdfs:label ?paintingLabel.
          }
        }
        GROUP BY ?item ?painting ?paintingLabel ?image
        LIMIT 10`,
        typeName: "Painting",
        baseDir: "/content/images/",
        verbose: "true"
      }
    },
  templates: {
    Painting: "/:item"
  }
}

Query SPARQL in Wikidata Query Service

property description mandatory default
url https://query.wikidata.org/sparql true
sparql SPARQL examples true
typeName Specify template correlation true
baseDir download file folder false /content/
cacheFile cache file name false .cache.json
cacheEnabled cache toggle false true
ttl time to live for cached values: ttl=0=infinite false 24 * 60 * 60 * 1000 ms = 24h
verbose set verbose mode false false

Open issues

  • add selective URI downloads with appropriate filter options
  • add a test coverage