Skip to content

Commit

Permalink
Add link (#27)
Browse files Browse the repository at this point in the history
* Add link

* Add hashtag option
  • Loading branch information
Dongri Jin authored Mar 8, 2023
1 parent be415fc commit b40d36f
Show file tree
Hide file tree
Showing 4 changed files with 919 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"type": "module",
"dependencies": {
"@atproto/api": "^0.1.3",
"autolinker": "^4.0.0",
"javascript-time-ago": "^2.5.9"
}
}
2 changes: 1 addition & 1 deletion src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function post() {
return;
}
const text = document.querySelector<HTMLInputElement>("textarea[name=text]")?.value as string;
const result = agent.api.app.bsky.feed.post.create(
const result = await agent.api.app.bsky.feed.post.create(
{ did: $session.did},
{ text, createdAt: new Date().toISOString() }
);
Expand Down
9 changes: 6 additions & 3 deletions src/lib/components/post.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<script lang="ts">
import type { AtpAgent } from "@atproto/api";
import TimeAgo from 'javascript-time-ago';
import en from 'javascript-time-ago/locale/en'
import en from 'javascript-time-ago/locale/en';
import Autolinker from 'autolinker';
TimeAgo.addDefaultLocale(en)
const autolinker = new Autolinker({newWindow: true, hashtag: 'twitter'});
type Post = Awaited<ReturnType<InstanceType<typeof AtpAgent>['api']['app']['bsky']['feed']['getTimeline']>>['data']['feed'][number];
export let post: Post;
Expand Down Expand Up @@ -32,6 +35,6 @@
</span>
</div>
<div class="message">
<div >{getText(post)}</div>
<div>{@html autolinker.link(getText(post) || '')}</div>
</div>
</div>
Loading

0 comments on commit b40d36f

Please sign in to comment.