8000 GitHub - danielsaidi/TagKit: A library that makes it easy to use tags and slugify strings in Swift & SwiftUI.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

danielsaidi/TagKit

Repository files navigation

Project Icon

Version Swift 5.9 Swift UI Documentation MIT License Sponsor my work

TagKit

TagKit is a library that makes it easy to use tags and slugify strings in Swift and SwiftUI.

You can slug and tag any type, customize the slug format, and use the built-in views to list and edit tags with ease.

Installation

TagKit can be installed with the Swift Package Manager:

https://github.com/danielsaidi/TagKit.git

Support My Work

You can become a sponsor to help me dedicate more time on my various open-source tools. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.

Getting started

TagKit lets you slugify strings and manage tags for any taggable type.

Slugs

Slugifying a string means to remove unwanted characters and replacing whitespaces with a separator. This is often used in urls, where a page slug creates a unique, valid url that also describes the content.

TagKit has a Swift/String/slugified(with:) string extension that lets you slugify strings with a standard or custom SlugConfiguration:

let custom = SlugConfiguration(
    separator: "+",
    allowedCharacters: .init(charactersIn: "hewo")
)

"Hello, world!".slugified()             // "hello-world" 
"Hello, world!".slugified(with: custom) // "he+wo"

Slugified strings are automatically lowercased, since a slug should be case-insensitively unique.

Tags

Tagging is the process of adding tags to an item, with the intent to categorize, group, filter and search among tags.

TagKit has a Taggable protocol that can be implemented by any type that has mutable Taggable/tags:

public protocol Taggable {

    var tags: [String] { get set }
}

Once a type implements Taggable, it can make use of a lot of automatically implemented functionality that the protocol provides, like Taggable/hasTags, Taggable/slugifiedTags, Taggable/addTag(_:), Taggable/removeTag(_:), Taggable/toggleTag(_:). All Taggable collections are extended as well.

Views

TagKit has a couple of tag related views, like TagList, TagEditList and TagTextField.

Documentation

The online documentation has more information, articles, code examples, etc.

Contact

Feel free to reach out if you have questions or if you want to contribute in any way:

License

TagKit is available under the MIT license. See the LICENSE file for more info.

About

A library that makes it easy to use tags and slugify strings in Swift & SwiftUI.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 
0