一个额外的组件集合,可以在 Publish 站点的 markdown 中使用。
要将其安装到您的 Publish 包中,请将其作为依赖项添加到您的 Package.swift
清单文件中
let package = Package(
dependencies: [
.package(name: "ExtraComponents", url: "https://github.com/markbattistella/extra-components-publish-plugin", from: "1.0.0")
],
targets: [
.target(
dependencies: [
"ExtraComponents"
]
)
]
)
然后导入 ExtraComponents
以便在任何您想使用它的地方使用
import ExtraComponents
有关如何使用 Swift Package Manager 的更多信息,请查看其官方文档。
然后,该插件可以像这样在任何发布管道中使用
import ExtraComponents
try DeliciousRecipes().publish(using: [
.installPlugin(.addExtraComponents())
])
默认情况下,它将从插件中添加默认 CSS 文件,以帮助设置组件样式。
但是,如果您希望在主 CSS 文件中添加自己的样式,请通过以下方式安装插件
import ExtraComponents
try DeliciousRecipes().publish(using: [
.installPlugin(.addExtraComponents(addCss: false))
])
我对 Swift 世界,特别是 iOS 以外的世界,只有非常基础的了解。
为此,我关闭了 Issues,如果您希望添加/更改代码库,请创建 Pull Request。
这样,每个人都可以让这些组件成长,并做到最好,而不是等待我来编写它。
git clone https://github.com/markbattistella/extra-components-publish-plugin.git
git checkout -b my-feature
git commit -am 'Add some feature'
git push origin my-new-feature
共有四种类型的警报:danger(危险)、warning(警告)、success(成功)和 information(信息)。
您可以使用带有前缀指示符的 blackquote 语法将它们添加到您的 markdown 文档中
> ! This is a `danger` alert notice
> % This is a `warning` alert notice
> / This is a `success` alert notice
> ? This is a `info` alert notice
指示符 | 输出类型 |
---|---|
! |
危险警报 |
% |
警告警报 |
/ |
成功警报 |
? |
信息警报 |
您还可以通过在标题前添加 :
,并在正文文本中使用新行来为警报通知添加标题
> ! :My danger title
This is a `danger` alert notice
> % :My warning title
This is a `warning` alert notice
> / :My success title
This is a `success` alert notice
> ? :My info title
This is a `info` alert notice
下载和参考链接在设计、实现和使用上非常相似,主要区别在于 Download
选项强制文件下载,而 references 选项则链接到参考。
下载应在新行上添加,并在其周围留有空格。如果在文本块中使用,则会导致问题。
这样设计的目的是让您可以添加一个漂亮的下载大按钮,以便人们能够获取您提供的任何附件。
您可以向下载添加不同的属性。这些是
属性 | 输出 |
---|---|
:title |
按钮的标签 |
:theme |
附加到 div 容器的类 |
:icon |
将添加到按钮左侧的 SVG 图标 |
[:file](/)
[:file](static/sample.txt)
[:file :title="My ~~custom~~ `title`" :theme="green" :icon="desktopDownload"](static/sample.txt)
[:file :title="My *file*" :theme=red :icon=rocket](static/sample.txt)
参考链接虽然与下载非常相似,但旨在引用您的 Publish 站点内的其他链接或外部站点。
同样,您也可以在参考中使用属性
属性 | 输出 |
---|---|
:title |
按钮的标签 |
:theme |
附加到 div 容器的类 |
:icon |
将添加到按钮左侧的 SVG 图标 |
:target |
是在同一页面还是新页面中打开 |
[:ref](/)
[:ref :title="This is my custom title"](/cars)
[:ref :title="Custom title" :icon="rocket"](/section/dogs/sausage-dogs)
[:ref :title="Custom title" :target="_blank"](../home/file/item/)
根据 Primer/Octicons 仓库,有 200 多个可用的图标可供使用。
您可以在此处找到所有可用图标的列表:https://octicons-primer.vercel.app/octicons/
任何名称中带有连字符的图标(例如 person-fill
)都可以通过驼峰式表示法 personFill
访问。