一个发布插件,可让您轻松地在您的网站中嵌入社交按钮(例如推文按钮)

社交按钮

一个发布插件,可让您轻松地在您的网站中嵌入社交按钮(例如推文按钮)。

安装

将其作为依赖项添加到 :Package.swift

let package = Package(
    ...

    dependencies: [
        .package(url: "https://github.com/alanpaivaa/SocialButtons", from: "0.1.0")
    ],
    targets: [
        .target(
            name: "AmazingBlog",
            dependencies: [
                "SocialButtons"
            ]
        )
    ]
)

用法

推特按钮

推文按钮允许用户轻松分享你网站的内容。

TweetButton(
    style: .small,                          // Choose small or large size
    text: "Check out my amazing article!",  // Text to be shared on the tweet
    hashTags: ["engineering", "swift"],     // Hash tags to be added on the tweet
    via: "alanpaivaa",                      // Twitter account for attribution
    related: ["other_user"]                 // Twitter accounts related to the shared content
)

若要呈现默认的推文按钮小部件,还需要加载 Twitter 小部件脚本:

HTML(
    .head(
        ...
        .loadTwitterWidgets()
    ),
    ...
)

If you need to customize the button, you can use a regular and build the Tweet url with . In that case, it’s also needed to set the parameter pointing to the page to share.LinkTweetURLGeneratorurl

Contribute

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! ?

I hope you enjoy it, thank you!

GitHub

点击跳转