Skip to content

Instantly share code, notes, and snippets.

@lukaskleinschmidt
Last active October 2, 2020 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaskleinschmidt/3cc809bdaa84c525bab364857fa6a3e6 to your computer and use it in GitHub Desktop.
Save lukaskleinschmidt/3cc809bdaa84c525bab364857fa6a3e6 to your computer and use it in GitHub Desktop.
Kirby Structure Field Preview
panel.plugin('lukaskleinschmidt/site', {
components: {
'k-structure-field-preview': {
props: {
value: String,
column: Object,
field: Object
},
computed: {
text: function() {
var result = [];
var fields = ['title', 'label'];
this.value.forEach(entry => fields.some(field => {
var value = entry[field] || null;
if (value) {
result.push(value);
return true;
}
}));
if (result.length) {
return result.join(', ');
}
return '…';
}
},
template: '<p class="k-structure-table-text">{{ text }}</p>',
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment