data endpoint for entity 90008 (aka. a website)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: handle isRecordWithMedia when converting from bsky post to note

dusk df91d052 4ea7f945

+67 -58
+67 -58
src/components/note.svelte
··· 1 1 <script module lang="ts"> 2 - import type { Post } from "@skyware/bot"; 2 + import type { Post } from '@skyware/bot'; 3 3 4 - export interface OutgoingLink { 5 - name: string, 6 - link: string, 7 - } 8 - export interface NoteData { 9 - content: string, 10 - published: number, 11 - hasMedia: boolean, 12 - hasQuote: boolean, 13 - outgoingLinks?: OutgoingLink[], 14 - } 4 + export interface OutgoingLink { 5 + name: string; 6 + link: string; 7 + } 8 + export interface NoteData { 9 + content: string; 10 + published: number; 11 + hasMedia: boolean; 12 + hasQuote: boolean; 13 + outgoingLinks?: OutgoingLink[]; 14 + } 15 15 16 - export const noteFromBskyPost = (post: Post): NoteData => { 17 - return { 18 - content: post.text, 19 - published: post.createdAt.getTime(), 20 - outgoingLinks: [{ name: "bsky", link: post.uri }], 21 - hasMedia: (post.embed?.isImages() || post.embed?.isVideo()) ?? false, 22 - hasQuote: post.embed?.isRecord() ?? false, 23 - } 24 - } 16 + export const noteFromBskyPost = (post: Post): NoteData => { 17 + return { 18 + content: post.text, 19 + published: post.createdAt.getTime(), 20 + outgoingLinks: [{ name: 'bsky', link: post.uri }], 21 + hasMedia: 22 + (post.embed?.isImages() || post.embed?.isVideo() || post.embed?.isRecordWithMedia()) ?? 23 + false, 24 + hasQuote: (post.embed?.isRecord() || post.embed?.isRecordWithMedia()) ?? false 25 + }; 26 + }; 25 27 </script> 28 + 26 29 <script lang="ts"> 27 - import Token from "./token.svelte"; 28 - import {renderDate, renderRelativeDate} from '$lib/dateFmt'; 30 + import Token from './token.svelte'; 31 + import { renderDate, renderRelativeDate } from '$lib/dateFmt'; 29 32 30 - interface Props { 31 - note: NoteData; 32 - isHighlighted?: boolean; 33 - onlyContent?: boolean; 34 - showOutgoing?: boolean; 35 - } 33 + interface Props { 34 + note: NoteData; 35 + isHighlighted?: boolean; 36 + onlyContent?: boolean; 37 + showOutgoing?: boolean; 38 + } 36 39 37 - let { 38 - note, 39 - isHighlighted = false, 40 - onlyContent = false, 41 - showOutgoing = true 42 - }: Props = $props(); 40 + let { note, isHighlighted = false, onlyContent = false, showOutgoing = true }: Props = $props(); 43 41 44 - const getOutgoingLink = (name: string, link: string) => { 45 - if (name === "bsky") { 46 - return `https://bsky.app/profile/gaze.systems/post/${link.split('/').pop()}` 47 - } 48 - return link 49 - } 50 - // this is ASS this should be a tailwind class 51 - const getTextShadowStyle = (color: string) => { 52 - return `text-shadow: 0 0 1px theme(colors.ralsei.black), 0 0 5px ${color};` 53 - } 54 - const outgoingLinkColors: Record<string, string> = { 55 - bsky: "rgb(0, 133, 255)", 56 - } 42 + const getOutgoingLink = (name: string, link: string) => { 43 + if (name === 'bsky') { 44 + return `https://bsky.app/profile/gaze.systems/post/${link.split('/').pop()}`; 45 + } 46 + return link; 47 + }; 48 + // this is ASS this should be a tailwind class 49 + const getTextShadowStyle = (color: string) => { 50 + return `text-shadow: 0 0 1px theme(colors.ralsei.black), 0 0 5px ${color};`; 51 + }; 52 + const outgoingLinkColors: Record<string, string> = { 53 + bsky: 'rgb(0, 133, 255)' 54 + }; 57 55 </script> 58 56 59 57 <p class="m-0 max-w-[70ch] text-wrap break-words leading-tight align-middle"> 60 - {#if !onlyContent}<Token title={renderDate(note.published)} v={renderRelativeDate(note.published)} small={!isHighlighted}/>{/if} <Token v={note.content} str/> 61 - {#if note.hasMedia}<Token v="-contains media-" keywd small/>{/if} 62 - {#if note.hasQuote}<Token v="-contains quote-" keywd small/>{/if} 63 - {#if showOutgoing} 64 - {#each note.outgoingLinks ?? [] as {name, link}} 65 - {@const color = outgoingLinkColors[name]} 66 - <span class="text-sm"><Token v="(" punct/><a class="hover:motion-safe:animate-squiggle hover:underline" style="color: {color};{getTextShadowStyle(color)}" href={getOutgoingLink(name, link)}>{name}</a><Token v=")" punct/></span> 67 - {/each} 68 - {/if} 69 - </p> 58 + {#if !onlyContent}<Token 59 + title={renderDate(note.published)} 60 + v={renderRelativeDate(note.published)} 61 + small={!isHighlighted} 62 + />{/if} 63 + <Token v={note.content} str /> 64 + {#if note.hasMedia}<Token v="-contains media-" keywd small />{/if} 65 + {#if note.hasQuote}<Token v="-contains quote-" keywd small />{/if} 66 + {#if showOutgoing} 67 + {#each note.outgoingLinks ?? [] as { name, link }} 68 + {@const color = outgoingLinkColors[name]} 69 + <span class="text-sm" 70 + ><Token v="(" punct /><a 71 + class="hover:motion-safe:animate-squiggle hover:underline" 72 + style="color: {color};{getTextShadowStyle(color)}" 73 + href={getOutgoingLink(name, link)}>{name}</a 74 + ><Token v=")" punct /></span 75 + > 76 + {/each} 77 + {/if} 78 + </p>