Use pure SVG files in your Publish projects💥
Add the package to your SPM dependencies.
.package(name: "SVGPublishPlugin", url: "https://github.com/c0dedbear/SVGPublishPlugin", from: "0.1.0"),
```swift
import SVGPublishPlugin
...
try YourWebSite().publish(
withTheme: .bearlogsTheme,
additionalSteps: [
...
],
plugins: [
.svgPlugin(),
...
]
)
☝Note that if your svg files not placed in the "Resources/svg", you must use 'folderPath' parameter of '.svgPlugin' method.
⚠️ There must be at least one file with .svg extension, in other case publish will throw an error on the install plugin step.
// Note that you don't need import plugin in places where you build your HTML
func makePageHTML(for page: Page, context: PublishingContext<Site>) throws -> HTML {
HTML(
.lang(context.site.language),
.head(for: page, on: context.site),
.body(
.header(for: context, selectedSection: nil),
.a(
.class(CSS.footerSectionTitle),
// File named `rss.svg` placed on folder path typed when installing plugin.
.svg("rss"),
.text("RSS feed"),
.href(Path.defaultForRSSFeed),
)
)
)
}
...
.svg("rss", parameters: .class(CSS.FooterRssIcon), .width(20), .height(20)),
...
.width and height - size of svg into pixels.
.classString - stylesheet's class name string
.class - StrongTypedCSS conformed class (see more on https://github.com/c0dedbear/StrongTypedCSSPublishPlugin)
.classes - array of StrongTypedCSS-conformed cases
...
import SVGPublishPlugin
....
enum SVG: String, SVGFileNameCase {
case logo
case search
case rss
case backToTop
}
// Inside of any HTML Node:
...
.svg(SVG.logo, parameters: .class(CSS.logoForFeaturedPosts)),
...
Mikhail Medvedev | https://bearlogs.ru
link |
Stars: 0 |
Last commit: 3 weeks ago |
Updated for Swift 5.5 and Publish 0.9.0
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics