https://github.com/cweinberger/linkattributespublishplugin
A Publish plugin to add support for link attributes and default link attributes
https://github.com/cweinberger/linkattributespublishplugin
plugin publish publish-plugin swift
Last synced: 2 months ago
JSON representation
A Publish plugin to add support for link attributes and default link attributes
- Host: GitHub
- URL: https://github.com/cweinberger/linkattributespublishplugin
- Owner: cweinberger
- License: mit
- Created: 2020-08-01T15:40:11.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2020-08-01T16:11:20.000Z (almost 5 years ago)
- Last Synced: 2025-02-03T14:25:54.978Z (4 months ago)
- Topics: plugin, publish, publish-plugin, swift
- Language: Swift
- Homepage: https://www.cweinberger.dev/
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LinkAttributes plugin for Publish
A [Publish](https://github.com/johnsundell/publish) plugin that allows you to specify link attributes.
Heavily inspired by https://github.com/finestructure/ImageAttributesPublishPlugin 🙌
## What it does
Markdown:
```markdown
[cweinberger.dev](https://cweinberger.dev rel=no-follow target=_blank)
```
Resulting HTML:
```html
```## Installation
To install **LinkAttributesPlugin** into your [Publish](https://github.com/johnsundell/publish) package, add it as a dependency to your `Package.swift` manifest:
```swift
let package = Package(
// ...
dependencies: [
// ...
.package(name: "LinkAttributesPublishPlugin", url: "https://github.com/cweinberger/LinkAttributesPublishPlugin", from: "1.0.0")
],
targets: [
.target(
// ...
dependencies: [
// ...
"LinkAttributesPublishPlugin"
]
)
]
// ...
)
```## Usage
Add this plugin to your publishing steps:
```swift
import LinkAttributesPublishPlugin
...
try DeliciousRecipes().publish(using: [
.installPlugin(.linkAttributes())
...
])
```## Default Attributes
You can add default attributes (e.g. `target="_blank"`) to all your links:
```swift
let linkConfig = LinkAttributesConfig(
defaultAttributes: [.init(key: "target", value: "_blank")]
)
try DeliciousRecipes().publish(using: [
.installPlugin(.linkAttributes(config: linkConfig))
...
])
```## Exclude Hosts From Adding Default Attributes
You can also exclude hosts from getting default attributes added:
```swift
let linkConfig = LinkAttributesConfig(
defaultAttributes: [.init(key: "target", value: "_blank")],
defaultAttributesHostExcludeList: [
"cweinberger.dev", // dont' add default attributes to websites with this hostname
"", // dont' add default attributes to websites without a hostname (relative links)
]
)try DeliciousRecipes().publish(using: [
.installPlugin(.linkAttributes(config: linkConfig))
...
])