generated from Princesseuh/component-template
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
138 additions
and
2 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
22 changes: 22 additions & 0 deletions
22
docs/src/content/docs/components/_examples/StyledToot.astro
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,22 @@ | ||
--- | ||
import { Toot } from '@astro-community/astro-embed-mastodon'; | ||
--- | ||
|
||
<div class="styled-toot"> | ||
<Toot id="https://m.webtoo.ls/@astro/112616562969236130" /> | ||
</div> | ||
|
||
<style> | ||
.styled-toot :global(.mastodon-toot) { | ||
background: floralwhite; | ||
color: darkblue; | ||
font-family: cursive; | ||
font-size: 1.25rem; | ||
border: 0; | ||
} | ||
|
||
.styled-toot :global(.mastodon-toot a) { | ||
color: purple; | ||
font-weight: bold; | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
title: Toot | ||
description: Learn how to use the Astro Embed Toot component to embed Mastodon posts in your website | ||
--- | ||
|
||
import { Tabs, TabItem } from '@astrojs/starlight/components'; | ||
import { Tweet } from '@astro-community/astro-embed-twitter'; | ||
import { Toot } from '@astro-community/astro-embed-mastodon'; | ||
|
||
The `<Toot>` component embeds posts from Mastodon in Astro projects. | ||
|
||
## Usage | ||
|
||
The `<Toot>` component generates a static Mastodon card for a single Toot using [Mastodon’s API](https://docs.joinmastodon.org/client/intro/). | ||
|
||
<Tabs> | ||
<TabItem label="Astro" icon="astro"> | ||
```astro | ||
--- | ||
import { Toot } from 'astro-embed'; | ||
--- | ||
<Toot id="https://m.webtoo.ls/@astro/112966069629573422" /> | ||
``` | ||
</TabItem> | ||
<TabItem label="MDX" icon="seti:markdown"> | ||
```mdx | ||
import { Toot } from 'astro-embed'; | ||
|
||
<Toot id="https://m.webtoo.ls/@astro/112966069629573422" /> | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
The above code produces the following result: | ||
|
||
<div> | ||
<Toot id="https://m.webtoo.ls/@astro/112966069629573422" /> | ||
</div> | ||
|
||
:::note | ||
The `<Toot>` component styles are intentionally minimal. | ||
They will match the font styles of your surrounding content. See [“Styling the Toot component”](#styling-the-toot-component) below for more details. | ||
::: | ||
|
||
## Styling the Toot component | ||
|
||
By default the `<Toot>` card has minimal styling, which should adapt to your site’s font settings etc. | ||
|
||
You can customise it by targeting the `.mastodon-toot` class, for example: | ||
|
||
```css | ||
.mastodon-toot { | ||
background: floralwhite; | ||
color: darkblue; | ||
font-family: cursive; | ||
font-size: 1.25rem; | ||
border: 0; | ||
} | ||
|
||
.mastodon-toot a { | ||
color: purple; | ||
font-weight: bold; | ||
} | ||
``` | ||
|
||
The above styles would render `<Toot>` like this: | ||
|
||
import StyledToot from './_examples/StyledToot.astro'; | ||
|
||
<StyledToot /> | ||
|
||
### Custom properties API | ||
|
||
The `<Toot>` component also supports a minimal API for controlling its styles by setting some CSS custom properties. | ||
|
||
```css | ||
:root { | ||
/* Control the padding inside the Mastodon card. */ | ||
--mc-padding: 1em; | ||
/* Set the border color of the Mastodon card. */ | ||
--mc-border-color: #cfd9de; | ||
} | ||
``` | ||
|
||
## Standalone installation | ||
|
||
If you only need the `<Toot>` component, you can install the package directly instead of the main `astro-embed` package: | ||
|
||
import { PackageManagers } from 'starlight-package-managers'; | ||
|
||
<PackageManagers pkg="@astro-community/astro-embed-mastodon" /> | ||
|
||
The `<Toot>` component can then be imported as: | ||
|
||
```js | ||
import { Toot } from '@astro-community/astro-embed-mastodon'; | ||
``` |
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