Swiftpack.co - markbattistella/heading-anchors-publish-plugin as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by markbattistella.
markbattistella/heading-anchors-publish-plugin 1.0.0
Add anchor links to your heading so you can easily share jump to links with others
⭐️ 0
🕓 3 weeks ago
.package(url: "https://github.com/markbattistella/heading-anchors-publish-plugin.git", from: "1.0.0")

Heading Anchors for Publish

Add anchor links to your headings so you can easily share them or let your users share them with others.

Installation

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.

Usage

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

Contributing

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.

How to help

  1. Clone the repo: git clone https://github.com/markbattistella/heading-anchors-publish-plugin
  2. Create your feature branch: git checkout -b my-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit the pull request

SVG icons

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

GitHub

link
Stars: 0
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Release Notes

Initial release
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics