Commit eef32521 authored by Tobias Steiner's avatar Tobias Steiner
Browse files

Add a target attribute and change the handling of 404

parent 93aa64d1
......@@ -51,6 +51,8 @@ The `tempate` is an optional parameter. You can provide your own template to mod
The `language` parameter is optional (default=de) and let you define the language of the provider. We resolve the name of the provider over the url pattern. Possible languages are `de`, `fr`, `it` and `en`.
### Timeout
The architecture of the `geolinker` waits for a certain timeout (default=2000) for the microservices to find an answer to the query. You can define that timeout. If you often get 404 try to set a higher timeout
### Link-target
By default the target of a link is `_blank`. If you wish to change this you can configure the zarget over the `link-target` attribute.
## Styling
The webcomponent uses a shadow dom and encapsulate the styles. So it will not use your sites default css styles but also not change any other styles in your site. There are two option to override the component default styles
### Slots
......
......@@ -45,7 +45,7 @@
}
ul li {
list-style: circle;
list-style: square;
}
</style>
<!-- You may hardcode stuff in here -->
......
......@@ -60,6 +60,7 @@
constructor() {
super();
this.attachShadow({mode: "open"});
this.linkTarget = '_blank';
Please register or sign in to reply
}
/**
......@@ -128,9 +129,14 @@
}
}
}
const response = await fetch(`${url}${location}?${params.join('&')}`);
const json = await response.json();
this.links = json.data[resolver].links;
try {
const response = await fetch(`${url}${location}?${params.join('&')}`);
const json = await response.json();
this.links = json.data[resolver].links;
} catch(error) {
// 404, no data or another error
this.links = [];
}
this.loading = false;
}
......@@ -154,6 +160,7 @@
const language = this.getAttribute('language') || null;
const timeout = this.getAttribute('timeout') || null;
const location = this.getAttribute('location') || window.location.href;
this.linkTarget = this.getAttribute('link-target') || '_blank';
if (typeof url === 'undefined' || typeof resolver === 'undefined' || typeof location === 'undefined') {
throw new Error("Missing required parameters");
}
......@@ -227,7 +234,7 @@
anchor = link;
}
// build the list
return `<li><a href="${href}"> ${anchor}</a></li>`;
return `<li><a href="${href}" target="${this.linkTarget}"> ${anchor}</a></li>`;
});
this._linksSlot.innerHTML = `<ul>${buildLinks().join("")}</ul>`;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment