Skip to content

Commit

Permalink
Use optional chaining when extracting values
Browse files Browse the repository at this point in the history
  • Loading branch information
martimpassos committed Jan 31, 2024
1 parent 2507c9c commit 0d87357
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class TropiiifyPlugin {


TropiiifyPlugin.defaults = {
itemTemplate: 'Tropy Generic',
itemTemplate: 'https://tropy.org/v1/templates/generic',
collectionName: 'My IIIF Collection',
homepageLabel: 'Object homepage',
requiredStatementLabel: 'Attribution',
Expand Down
3 changes: 1 addition & 2 deletions src/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ class Resource {
y: this.extractValue(selection, tropy('y')),
width: this.extractValue(selection, tropy('width')),
height: this.extractValue(selection, tropy('height')),

}))
}))

console.log('Constructed object:', this)
}

extractValue(data, property) {
return data[property]?.[0]['@value'] || data[property]?.[0]['@list'];
return data?.[property]?.[0]?.['@value'] || data?.[property]?.[0]?.['@list'];
}

assembleHTML(property) {
Expand Down

0 comments on commit 0d87357

Please sign in to comment.