diff --git a/src/tagsDisplay.js b/src/tagsDisplay.js
index 5bbda592..af068c6d 100644
--- a/src/tagsDisplay.js
+++ b/src/tagsDisplay.js
@@ -3,22 +3,22 @@ const OverpassLayer = require('overpass-layer')
const formatter = [
{
regexp: /^(.*:)?wikidata$/,
- format: '{{ value }}'
+ link: 'https://wikidata.org/wiki/{{ value|url_encode }}'
},
{
regexp: /^(.*:)wikipedia$/,
- format: '{% set v = value|split(":") %}{{ value }}'
+ link: '{% set v = value|split(":") %}https://{{ v[0]|url_encode }}.wikipedia.org/wiki/{{ v[1]|replace({" ": "_"}) }}'
},
{
regexp: /^(website|url|contact:website)$/,
- format: '{{ value }}'
+ link: '{{ value|websiteUrl }}'
},
{
regexp: /^(image|wikimedia_commons)$/,
- format: '{% if value matches "/^(File|Category):/" %}' +
- '{{ value }}' +
+ link: '{% if value matches "/^(File|Category):/" %}' +
+ 'https://commons.wikimedia.org/wiki/{{ value|replace({" ": "_"}) }}' +
'{% else %}' +
- '{{ value }}' +
+ '{{ value }}' +
'{% endif %}'
}
]
@@ -30,7 +30,11 @@ module.exports = function tagsDisplay (tags) {
if (!compiled) {
defaultTemplate = OverpassLayer.twig.twig({ data: '{{ value }}', autoescape: true })
for (let i in formatter) {
- formatter[i].template = OverpassLayer.twig.twig({ data: formatter[i].format, autoescape: true })
+ if (formatter[i].format) {
+ formatter[i].template = OverpassLayer.twig.twig({ data: formatter[i].format, autoescape: true })
+ } else {
+ formatter[i].template = OverpassLayer.twig.twig({ data: '{{ value }}', autoescape: true })
+ }
}
compiled = true