Skip to content

Commit

Permalink
fix label generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Flick committed Jun 23, 2024
1 parent c28b7cc commit 223c359
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
const generateLabel = (/** @type {String[]} */ sigla) => {
const info = [...data.codices, ...data.fragments];
sigla.map((s) => {
const found = info.find((i) => i.sigil === s);
sigla = sigla.map((s) => {
const found = info.find((i) => i.handle === s);
if (found) {
const { sigil, handle, ...rest } = found;
return `${sigil} (${rest})`;
const { sigil, loc, cod } = found;
const location = loc ? `Standort: ${loc}` : '';
const codex = cod ? `Codex: ${cod}` : '';
return `<abbr title='${[location, codex].join(', ')}'>${sigil}</abbr>`;
}
return s;
});
Expand Down Expand Up @@ -67,7 +69,7 @@
<div class="grid gap-6 md:grid-cols-2 md:my-8">
<p>
Dies ist die Textzeugenansicht. Derzeit {Number(data.content?.length) > 1 ? 'werden' : 'wird'}
{data?.content ? generateLabel(selectedSigla) : 'keine Textzeugen'} angezeigt. Mit dem Selektor
{@html data?.content ? generateLabel(selectedSigla) : 'keine Textzeugen'} angezeigt. Mit dem Selektor
können Sie die Textzeugen wechseln.
</p>
<TextzeugenSelector
Expand All @@ -85,7 +87,7 @@
>
<section>
<div class="mb-4 relative">
<h2 class="h2">Textzeuge: {generateLabel([content.sigla])}</h2>
<h2 class="h2">Textzeuge: {@html generateLabel([content.sigla])}</h2>
<p>
Vers: {localVerses[i]}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
for (let i = 0; i < children.length; i++) {
const child = children[i];
if (child.children.length === 0) {
if (child.textContent.trim() !== '') {
if (child.textContent?.trim() !== '') {
return false;
}
} else {
Expand Down

0 comments on commit 223c359

Please sign in to comment.