blog umami fix
This commit is contained in:
@@ -3,9 +3,11 @@ import type { WordpressPost } from "../lib/content/types";
|
||||
|
||||
type Props = {
|
||||
post: WordpressPost;
|
||||
placement: string;
|
||||
targetId: string;
|
||||
};
|
||||
|
||||
const { post } = Astro.props;
|
||||
const { post, placement, targetId } = Astro.props;
|
||||
|
||||
function truncate(s: string, n: number) {
|
||||
if (!s) return "";
|
||||
@@ -15,11 +17,17 @@ function truncate(s: string, n: number) {
|
||||
}
|
||||
---
|
||||
|
||||
<a class="blog-card" href={`/blog/post/${post.slug}`}>
|
||||
<a
|
||||
class="blog-card"
|
||||
href={`/blog/post/${post.slug}`}
|
||||
data-umami-event="click"
|
||||
data-umami-event-target_id={targetId}
|
||||
data-umami-event-placement={placement}
|
||||
data-umami-event-target_url={`/blog/post/${post.slug}`}
|
||||
>
|
||||
{post.featuredImageUrl ? <img src={post.featuredImageUrl} alt="" loading="lazy" /> : null}
|
||||
<div class="blog-card-body">
|
||||
<h3 class="blog-card-title">{post.title}</h3>
|
||||
<p class="blog-card-excerpt">{truncate(post.excerpt || "", 180)}</p>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
|
||||
@@ -10,16 +10,36 @@ const { categories, activeCategorySlug } = Astro.props;
|
||||
---
|
||||
|
||||
<nav class="subnav" aria-label="Blog categories">
|
||||
<a class={!activeCategorySlug ? "active" : ""} href="/blog">
|
||||
<a
|
||||
class={!activeCategorySlug ? "active" : ""}
|
||||
href="/blog"
|
||||
data-umami-event="click"
|
||||
data-umami-event-target_id="blog.subnav.all"
|
||||
data-umami-event-placement="blog.subnav"
|
||||
data-umami-event-target_url="/blog"
|
||||
>
|
||||
All
|
||||
</a>
|
||||
<a class={activeCategorySlug === "__pages" ? "active" : ""} href="/blog/pages">
|
||||
<a
|
||||
class={activeCategorySlug === "__pages" ? "active" : ""}
|
||||
href="/blog/pages"
|
||||
data-umami-event="click"
|
||||
data-umami-event-target_id="blog.subnav.pages"
|
||||
data-umami-event-placement="blog.subnav"
|
||||
data-umami-event-target_url="/blog/pages"
|
||||
>
|
||||
Pages
|
||||
</a>
|
||||
{categories.map((c) => (
|
||||
<a class={activeCategorySlug === c.slug ? "active" : ""} href={`/blog/category/${c.slug}`}>
|
||||
<a
|
||||
class={activeCategorySlug === c.slug ? "active" : ""}
|
||||
href={`/blog/category/${c.slug}`}
|
||||
data-umami-event="click"
|
||||
data-umami-event-target_id={`blog.subnav.category.${c.slug}`}
|
||||
data-umami-event-placement="blog.subnav"
|
||||
data-umami-event-target_url={`/blog/category/${c.slug}`}
|
||||
>
|
||||
{c.name}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user