Add anchor links to your headings so you can easily share them or let your users share them with others.
To install it into your Publish package, add it as a dependency within your Package.swift
manifest:
let package = Package(
dependencies: [
.package(name: "HeadingAnchors", url: "https://github.com/markbattistella/heading-anchors-publish-plugin", from: "1.0.0")
],
targets: [
.target(
dependencies: [
"HeadingAnchors"
]
)
]
)
Then import HeadingAnchors
wherever you’d like to use it:
import HeadingAnchors
For more information on how to use the Swift Package Manager, check out its official documentation.
The plugin can then be used within any publishing pipeline like this:
import HeadingAnchors
try DeliciousRecipes().publish(using: [
...
.installPlugin(.addHeadingAnchors())
...
])
By default it will add in the default CSS files from the plugin to help style your components.
However if you wish to add your own in your main CSS file, install the plugin by:
import ExtraComponents
try DeliciousRecipes().publish(using: [
.installPlugin(.addHeadingAnchors(addCSS: false))
])
You will have to add the CSS file into your Stylesheets
array in your custom theme.
There are other options too avaialble.
Parameter | Type | Usage |
---|---|---|
upto: |
Int |
Determines which heading tags should get anchor links. It starts at <h1> and the number you put tells the loop where to stop. Example, entering 4 will mean all <h1> , <h2> , <h3> , and <h4> will get anchor links, but <h5> and <h6> will not. |
icon: |
Icon |
Select from the 14 icons which you can use to have as the anchor link |
addCSS: |
Bool |
Whether the predefined CSS will be added into your Output folder |
path: |
Path |
Select where in the Output folder your CSS file will be written to if using the default CSS |
I've turned off Issues and if you wish to add/change the codebase please create a Pull Request.
This way everyone can allow this plugin to grow, and be the best rather than waiting on me to write it.
- Clone the repo:
git clone https://github.com/markbattistella/heading-anchors-publish-plugin
- Create your feature branch:
git checkout -b my-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit the pull request
There are 14 anchor icons you can select to have next to your headings:
SVG | enum Selection |
---|---|
link |
|
hash |
|
bookmark |
|
bookmarkFilled |
|
dot |
|
dotFilled |
|
flame |
|
heart |
|
heartFilled |
|
external |
|
northStar |
|
book |
|
star |
|
starFilled |