Fixed image url in news list
This commit is contained in:
parent
7431087d7a
commit
a6d1468a2a
|
|
@ -27,7 +27,7 @@ const location = [data.data.city, data.data.state, countryName].filter(Boolean).
|
||||||
|
|
||||||
const newsUrl = `/${locale}/${getLocalizedRoute(routeKey, locale)}/${data.id}`;
|
const newsUrl = `/${locale}/${getLocalizedRoute(routeKey, locale)}/${data.id}`;
|
||||||
|
|
||||||
const rawContent = content?.body || "";
|
const rawContent = data.data?.body || "";
|
||||||
const plainText = rawContent.replace(/^#.*$/gm, "").replace(/^###.*$/gm, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/_([^_]+)_/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/^>.*$/gm, "").replace(/`[^`]+`/g, "").replace(/^[-*]\s+/gm, "").trim();
|
const plainText = rawContent.replace(/^#.*$/gm, "").replace(/^###.*$/gm, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/_([^_]+)_/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/^>.*$/gm, "").replace(/`[^`]+`/g, "").replace(/^[-*]\s+/gm, "").trim();
|
||||||
const words = plainText.split(/\s+/).filter((w) => w.length > 0).slice(0, 40);
|
const words = plainText.split(/\s+/).filter((w) => w.length > 0).slice(0, 40);
|
||||||
const excerpt = words.join(" ") + (words.length === 40 ? "..." : "");
|
const excerpt = words.join(" ") + (words.length === 40 ? "..." : "");
|
||||||
|
|
@ -36,7 +36,7 @@ const excerpt = words.join(" ") + (words.length === 40 ? "..." : "");
|
||||||
<a href={newsUrl} class="block group">
|
<a href={newsUrl} class="block group">
|
||||||
<article class="flex flex-col md:flex-row gap-6 md:gap-8 p-4 md:p-6 border-b border-tertiary/20 hover:bg-tertiary/5 transition-colors">
|
<article class="flex flex-col md:flex-row gap-6 md:gap-8 p-4 md:p-6 border-b border-tertiary/20 hover:bg-tertiary/5 transition-colors">
|
||||||
<div class="md:w-1/3 flex-shrink-0 overflow-hidden justify-center items-center flex">
|
<div class="md:w-1/3 flex-shrink-0 overflow-hidden justify-center items-center flex">
|
||||||
<Image src={data.data.thumbnail_square || data.data.thumbnail} alt={data.data.title} width={480} class="w-full h-auto object-contain transform group-hover:scale-105 transition-transform duration-300" />
|
<Image src={data.data.thumbnail_square || data.data.thumbnail?.url} alt={data.data.title} width={480} class="w-full h-auto object-contain transform group-hover:scale-105 transition-transform duration-300" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="md:w-2/3 flex flex-col">
|
<div class="md:w-2/3 flex flex-col">
|
||||||
|
|
@ -52,7 +52,7 @@ const excerpt = words.join(" ") + (words.length === 40 ? "..." : "");
|
||||||
{data.data.tags && data.data.tags.length > 0 && (
|
{data.data.tags && data.data.tags.length > 0 && (
|
||||||
<div class="flex flex-nowrap md:flex-wrap gap-2 overflow-x-auto md:overflow-visible pb-2 md:pb-0 mb-4">
|
<div class="flex flex-nowrap md:flex-wrap gap-2 overflow-x-auto md:overflow-visible pb-2 md:pb-0 mb-4">
|
||||||
{data.data.tags.map((tag: string) => (
|
{data.data.tags.map((tag: string) => (
|
||||||
<span class="badge rounded-none bg-[#EBE6D2] border-none text-[#003421] whitespace-nowrap">{tag}</span>
|
<span class="badge rounded-none bg-[#EBE6D2] border-none text-[#003421] whitespace-nowrap">{Tag}</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue