gridsome-source-gmaps-geocode
Advanced tools
Comparing version
15
index.js
@@ -8,3 +8,4 @@ class GmapGeocodeSource { | ||
index: ['index'], | ||
typeName: 'GmapGeocode' | ||
typeName: 'GmapGeocode', | ||
geocodeField: 'geocode' | ||
} | ||
@@ -26,3 +27,6 @@ } | ||
async createNodes(actions) { | ||
const geocodeCollection = actions.addCollection('GmapGeocode') | ||
let geocodeCollection | ||
if (!(geocodeCollection = actions.getCollection('GmapGeocode'))) { | ||
geocodeCollection = actions.addCollection('GmapGeocode') | ||
} | ||
const sourceCollection = actions.getCollection(this.options.sourceTypeName) | ||
@@ -35,5 +39,6 @@ const sourceNodes = sourceCollection.data() | ||
if (results.length > 0) { | ||
const geo = results[0].geometry.location | ||
const geoNode = geocodeCollection.addNode({lat: geo.lat, lng: geo.lng}) | ||
sourceNode.geocode = actions.store.createReference(geoNode) | ||
const result = results[0] | ||
const geo = result.geometry.location | ||
const geoNode = geocodeCollection.addNode({id: result.place_id, lat: geo.lat, lng: geo.lng}) | ||
sourceNode[this.options.geocodeField] = actions.store.createReference(geoNode) | ||
sourceCollection.updateNode(sourceNode) | ||
@@ -40,0 +45,0 @@ } |
{ | ||
"name": "gridsome-source-gmaps-geocode", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Geocode data from your Gridsome sources using the Google Maps Geocoding API.", | ||
"main": "index.js", | ||
"author": "James Hall", | ||
"repository": "https://github.com/iam-jam/gridsome-source-gmaps-geocode", | ||
"keywords": [ | ||
@@ -8,0 +9,0 @@ "gridsome", |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
2938
10.45%47
11.9%