forked from cms/tibi-svelte-starter
Möglichkeit, in die Artikel-Details zu springen implementiert, ohne einen extra URL Pfad zu benötigen.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { fade } from "svelte/transition"
|
||||
import { _ } from "svelte-i18n"
|
||||
// import { navigate } from "svelte-routing"
|
||||
import { navigate, link } from "svelte-routing"
|
||||
|
||||
import TibiArticleMediaFile from "./TibiArticleMediaFile.svelte"
|
||||
|
||||
@@ -9,6 +8,7 @@
|
||||
export let cssClass: string = ""
|
||||
export let showDetails: boolean = false
|
||||
|
||||
let path = window.location.pathname
|
||||
let article = null
|
||||
if (entry) {
|
||||
article = entry.article
|
||||
@@ -201,6 +201,21 @@
|
||||
|
||||
{#if article?.content?.types?.details && showDetails}
|
||||
<div class="article-details">{@html article?.content?.types?.details}</div>
|
||||
{:else if article?.content?.types?.details}
|
||||
<a
|
||||
use:link
|
||||
href="{`${path}${encodeURIComponent(
|
||||
article?.content?.slug
|
||||
? article?.content?.slug
|
||||
.toLowerCase()
|
||||
.replace(/[^a-zA-Z0-9]/g, '-')
|
||||
.replaceAll('---', '--')
|
||||
: entry.id
|
||||
)}`}"
|
||||
class="article-link"
|
||||
>
|
||||
{@html article?.link?.text ? article?.link?.text : $_("details")}
|
||||
</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user