fix(runtime): stabilize navigation and custom errors
This commit is contained in:
@@ -13,9 +13,23 @@ component Footer {
|
||||
columns: number = 3
|
||||
maxWidth: string = "compact"
|
||||
copyright: string = ""
|
||||
copyrightKey: string = ""
|
||||
translationPrefix: string = ""
|
||||
class: string = ""
|
||||
}
|
||||
|
||||
functions {
|
||||
shared function translationKey(item, field) {
|
||||
if (!item) return ""
|
||||
const explicit = item[field + "Key"]
|
||||
if (explicit) return explicit
|
||||
if (!translationPrefix) return ""
|
||||
const source = item.value || item.href || item.label || item.title || ""
|
||||
const slug = String(source).replace(/^\/+|\/+$/g, "").replace(/[^A-Za-z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase()
|
||||
return slug ? translationPrefix + "." + slug + (field === "description" ? ".description" : "") : ""
|
||||
}
|
||||
}
|
||||
|
||||
view {
|
||||
<footer
|
||||
{...attrs}
|
||||
@@ -58,12 +72,13 @@ component Footer {
|
||||
<h2
|
||||
id='footer-heading-{itemIndex}'
|
||||
class="wrn-footer__heading"
|
||||
data-t='{translationKey(item, "label")}'
|
||||
>
|
||||
{item.label || item.title}
|
||||
</h2>
|
||||
|
||||
{#if item.description}
|
||||
<p>
|
||||
<p data-t='{translationKey(item, "description")}'>
|
||||
{item.description}
|
||||
</p>
|
||||
{/if}
|
||||
@@ -77,7 +92,7 @@ component Footer {
|
||||
href='{child.href || "#"}'
|
||||
target='{child.target || ""}'
|
||||
rel='{child.external ? "noopener noreferrer" : (child.rel || "")}'
|
||||
aria-current='{child.active ? "page" : ""}'
|
||||
aria-current='{child.active ? "page" : "false"}'
|
||||
class="wrn-footer__link"
|
||||
@click='output.select({ item: child, parent: item, itemIndex: childIndex, sectionIndex: itemIndex }); child.action && output.action({ item: child, parent: item, itemIndex: childIndex, sectionIndex: itemIndex })'
|
||||
>
|
||||
@@ -89,7 +104,7 @@ component Footer {
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
<span>
|
||||
<span data-t='{translationKey(child, "label")}'>
|
||||
{child.label || child.title}
|
||||
</span>
|
||||
|
||||
@@ -125,7 +140,7 @@ component Footer {
|
||||
href='{item.href || "#"}'
|
||||
target='{item.target || ""}'
|
||||
rel='{item.external ? "noopener noreferrer" : (item.rel || "")}'
|
||||
aria-current='{item.active ? "page" : ""}'
|
||||
aria-current='{item.active ? "page" : "false"}'
|
||||
class="wrn-footer__link"
|
||||
@click='output.select({ item: item, itemIndex: itemIndex }); item.action && output.action({ item: item, itemIndex: itemIndex })'
|
||||
>
|
||||
@@ -137,7 +152,7 @@ component Footer {
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
<span>
|
||||
<span data-t='{translationKey(item, "label")}'>
|
||||
{item.label || item.title}
|
||||
</span>
|
||||
|
||||
@@ -177,6 +192,7 @@ component Footer {
|
||||
<h2
|
||||
id='footer-heading-{itemIndex}'
|
||||
class="wrn-footer__heading"
|
||||
data-t='{translationKey(item, "label")}'
|
||||
>
|
||||
{item.title || item.label}
|
||||
</h2>
|
||||
@@ -264,7 +280,7 @@ component Footer {
|
||||
<p
|
||||
class="wrn-footer__copyright"
|
||||
>
|
||||
{copyright}
|
||||
<span data-t='{copyrightKey}'>{copyright}</span>
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user