This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
forked from elk-zone/elk
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/glean-add-real-data
- Loading branch information
Showing
3 changed files
with
65 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script setup lang="ts"> | ||
import type { Recommendation } from '../composables/recommendations' | ||
const { | ||
item, | ||
} = defineProps<{ | ||
item: Recommendation | ||
}>() | ||
const target = ref<HTMLDivElement>() | ||
const { isActive } = useIntersectionObserver(target, checkIntersection, { threshold: 0.5 }) | ||
function checkIntersection([{ isIntersecting }]: [{ isIntersecting: boolean }]): void { | ||
if (isIntersecting && isActive.value) { | ||
// fire analytics event here: item.id || item.title || item.url | ||
isActive.value = false | ||
} | ||
} | ||
// Shorten a string to less than maxLen characters without truncating words. | ||
function shorten(str: string, maxLen: number): string { | ||
if (str.length <= maxLen) | ||
return str | ||
return `${str.slice(0, str.lastIndexOf(' ', maxLen))}...` | ||
} | ||
const clipboard = useClipboard() | ||
async function copyLink(url: string, event: Event): void { | ||
event.preventDefault() | ||
if (url) | ||
await clipboard.copy(url) | ||
} | ||
</script> | ||
|
||
<template> | ||
<NuxtLink ref="target" :to="item.url" target="_blank" external p-y-16px p-x-8px flex border="b base"> | ||
<div class="content" w-full pr> | ||
<h4 text-sm text-secondary> | ||
{{ item.publisher }} | ||
</h4> | ||
<h3 text-lg line-height-tight font-500 m-y-4px> | ||
{{ shorten(item.title, 100) }} | ||
</h3> | ||
<p> | ||
{{ shorten(item.excerpt, 140) }} | ||
</p> | ||
</div> | ||
<div class="media" relative overflow-hidden max-w-120px min-w-120px> | ||
<img :src="item.image.sizes?.[0]?.url" rounded-lg overflow-hidden w-full ha> | ||
<div m-y-4px flex flex-justify-end> | ||
<button p-12px text-xl @click="copyLink(item.url, $event)"> | ||
<div i-ri:share-line /> | ||
</button> | ||
</div> | ||
</div> | ||
</NuxtLink> | ||
</template> | ||
<style scoped> | ||
a:hover h3 { | ||
text-decoration: underline; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters