Skip to content

Commit 9ce923e

Browse files
authored
Merge pull request #335 from spences10/feat/add-toot
2 parents b080462 + 9059758 commit 9ce923e

File tree

5 files changed

+87
-4
lines changed

5 files changed

+87
-4
lines changed

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# SvelteKit Embed
22

33
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4+
45
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
6+
57
<!-- ALL-CONTRIBUTORS-BADGE:END -->
68

79
[![MadeWithSvelte.com shield](https://madewithsvelte.com/storage/repo-shields/3786-shield.svg)](https://madewithsvelte.com/p/sveltekit-embed/shield-link)
@@ -11,9 +13,9 @@ packaged up for use.
1113

1214
![sveltekit embed cover](.github/sveltekit-embed.jpg)
1315

14-
Each component is wrapped in an intersection observer
15-
`GeneralObserver` which will load up the component when it scrolls
16-
into the viewport.
16+
Each component with the exception of `Toot` and `Tweet` is wrapped in
17+
an intersection observer `GeneralObserver` which will load up the
18+
component when it scrolls into the viewport.
1719

1820
## Use
1921

@@ -81,6 +83,31 @@ Credit to [@pauliescanlon](https://github.com/pauliescanlon) for the
8183
original version of this project in
8284
[MDX Embed](https://github.com/pauliescanlon/mdx-embed).
8385

86+
## Packaging for NPM
87+
88+
Scott, this is here for you to remember how to do this 🙃
89+
90+
Although I detailed this in
91+
[Making npm Packages with SvelteKit](https://scottspence.com/posts/making-npm-packages-with-sveltekit)
92+
I think it's best to put it here as I always come to the README and
93+
the instructions are never there! 😅
94+
95+
**Publish the project to NPM**
96+
97+
```bash
98+
# authenticate with npm
99+
npm login
100+
# bump version with npm
101+
npm version 0.0.2
102+
# package with sveltkit
103+
pnpm run package
104+
# publish from package directory
105+
cd package
106+
npm publish
107+
# push tags to github
108+
git push --tags
109+
```
110+
84111
## Contributors ✨
85112

86113
Thanks goes to these wonderful people

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sveltekit-embed",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"author": {
55
"name": "Scott Spence",
66
"email": "yo@scottspence.dev",

src/lib/components/toot.svelte

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script lang="ts">
2+
export let instance: string = ''
3+
export let username: string = ''
4+
export let tootId: string = ''
5+
</script>
6+
7+
<svelte:head>
8+
<script
9+
async
10+
src="https://mas.to/embed.js"
11+
charset="utf-8"
12+
></script>
13+
</svelte:head>
14+
15+
<div class="flex justify-center mb-12">
16+
<iframe
17+
title=""
18+
src={`https://${instance}/${
19+
username.slice(0, 1) === `@` ? username : `@` + username
20+
}/${tootId}/embed`}
21+
class="mastodon-embed"
22+
style="max-width: 100%; border: 0"
23+
width="400"
24+
allowfullscreen
25+
/>
26+
</div>

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export { default as SimpleCast } from './components/simple-cast.svelte'
88
export { default as SoundCloud } from './components/sound-cloud.svelte'
99
export { default as Spotify } from './components/spotify.svelte'
1010
export { default as StackBlitz } from './components/stackblitz.svelte'
11+
export { default as Toot } from './components/toot.svelte'
1112
export { default as Tweet } from './components/tweet.svelte'
1213
export { default as Vimeo } from './components/vimeo.svelte'
1314
export { default as YouTube } from './components/you-tube.svelte'

src/routes/+page.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
SoundCloud,
1010
Spotify,
1111
StackBlitz,
12+
Toot,
1213
Tweet,
1314
Vimeo,
1415
YouTube,
@@ -287,6 +288,34 @@ Output:
287288

288289
<StackBlitz id="vitejs-vite-yyoood" hideNavigation />
289290

291+
## Toot
292+
293+
Props:
294+
295+
```ts
296+
instance: string = ''
297+
username: string = ''
298+
tootId: string = ''
299+
```
300+
301+
Usage:
302+
303+
```html
304+
<Toot
305+
instance="mas.to"
306+
username="@spences10"
307+
tootId="109252587760962553"
308+
/>
309+
```
310+
311+
Output:
312+
313+
<Toot
314+
instance="mas.to"
315+
username="@spences10"
316+
tootId="109252587760962553"
317+
/>
318+
290319
## Tweet
291320

292321
Props:

0 commit comments

Comments
 (0)