Skip to content

Commit d02ef33

Browse files
authored
Update README.md
1 parent 7f83a80 commit d02ef33

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
11
# SocialButtons
22

3-
A description of this package.
3+
A plugin for [Publish](https://github.com/JohnSundell/Publish) that allows you to easily embed social buttons (e.g. Tweet button) in your site.
4+
5+
## Installation
6+
Add it as a dependency in `Package.swift`:
7+
8+
```swift
9+
let package = Package(
10+
...
11+
12+
dependencies: [
13+
.package(url: "https://github.com/alanpaivaa/SocialButtons", from: "0.1.0")
14+
],
15+
targets: [
16+
.target(
17+
name: "AmazingBlog",
18+
dependencies: [
19+
"SocialButtons"
20+
]
21+
)
22+
]
23+
)
24+
```
25+
26+
## Usage
27+
28+
### TweetButton
29+
A [Tweet button](https://developer.twitter.com/en/docs/twitter-for-websites/tweet-button/overview) allows users easily share content from your site.
30+
31+
```swift
32+
TweetButton(
33+
style: .small, // Choose small or large size
34+
text: "Check out my amazing article!", // Text to be shared on the tweet
35+
hashTags: ["engineering", "swift"], // Hash tags to be added on the tweet
36+
via: "alanpaivaa", // Twitter account for attribution
37+
related: ["other_user"] // Twitter accounts related to the shared content
38+
)
39+
```
40+
41+
To render the default Tweet button widget, it's also necessary to load the Twitter widget script:
42+
43+
```swift
44+
HTML(
45+
.head(
46+
...
47+
.loadTwitterWidgets()
48+
),
49+
...
50+
)
51+
```
52+
53+
If you need to customize the button, you can use a regular `Link` and build the Tweet url with `TweetURLGenerator`. In that case, it's also needed to set the `url` parameter pointing to the page to share.
54+
55+
56+
## Contribute
57+
58+
This project is in its early development and community is highly encouraged to contribute, either by adding more components, fixing bugs or improving documentation. Thus, feel free to go ahead and create a Pull Request! 💯
59+
60+
I hope you enjoy it, thank you!

0 commit comments

Comments
 (0)