Skip to content

markbattistella/heading-anchors-publish-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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