Skip to content

Commit 364d397

Browse files
committed
Cleanup file structure
1 parent 0cb74c9 commit 364d397

16 files changed

+104
-139
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022-2024 Daniel Saidi
3+
Copyright (c) 2022-2025 Daniel Saidi
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Sources/TagKit/SlugConfiguration.swift renamed to Sources/TagKit/Slugs.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
//
2-
// SlugConfiguration.swift
2+
// Slugs.swift
33
// TagKit
44
//
55
// Created by Daniel Saidi on 2022-08-18.
6-
// Copyright © 2022-2024 Daniel Saidi. All rights reserved.
6+
// Copyright © 2022-2025 Daniel Saidi. All rights reserved.
77
//
88

99
import Foundation
1010

11+
public extension String {
12+
13+
/// Create a slugified version of the string.
14+
///
15+
/// - Parameters:
16+
/// - configuration: The configuration to use, by default ``SlugConfiguration/standard``.
17+
func slugified(
18+
with configuration: SlugConfiguration = .standard
19+
) -> String {
20+
lowercased()
21+
.components(separatedBy: configuration.notAllowedCharacterSet)
22+
.filter { !$0.isEmpty }
23+
.joined(separator: configuration.separator)
24+
}
25+
}
26+
1127
/// This configuration defines how ``Slugifiable`` types are
1228
/// slugified.
1329
///

Sources/TagKit/String+Slugified.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

Sources/TagKit/TagKit.docc/TagKit.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TagKit is a Swift SDK that makes it easy to work with tags and slugification in
1010

1111
TagKit is a Swift SDK that makes it easy to work with tags and slugified strings in `Swift` and `SwiftUI`.
1212

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

1515

1616

@@ -85,14 +85,12 @@ TagKit is available under the MIT license.
8585

8686
## Topics
8787

88-
### Articles
88+
### Slugs
8989

90-
- <doc:Getting-Started>
90+
- ``SlugConfiguration``
9191

92-
### Types
92+
### Tags
9393

94-
- ``Slugifiable``
95-
- ``SlugConfiguration``
9694
- ``Taggable``
9795

9896
### Views

Sources/TagKit/Taggable+Collection.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

Sources/TagKit/Taggable.swift renamed to Sources/TagKit/Tags.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//
2-
// Taggable.swift
2+
// Tags.swift
33
// TagKit
44
//
55
// Created by Daniel Saidi on 2022-08-06.
6-
// Copyright © 2022-2024 Daniel Saidi. All rights reserved.
6+
// Copyright © 2022-2025 Daniel Saidi. All rights reserved.
77
//
88

99
import Foundation
@@ -60,7 +60,7 @@ public extension Taggable {
6060
func slugifiedTags(
6161
configuration: SlugConfiguration = .standard
6262
) -> [String] {
63-
tags.map { $0.slugified(configuration: configuration) }
63+
tags.map { $0.slugified(with: configuration) }
6464
}
6565

6666
/// Toggle a tag on the taggable type.
@@ -72,3 +72,19 @@ public extension Taggable {
7272
}
7373
}
7474
}
75+
76+
public extension Collection where Element: Taggable {
77+
78+
/// Get all the slugified tags in the collection.
79+
///
80+
/// Read more about slugified strings in ``Slugifiable``.
81+
var allTags: [String] {
82+
let slugs = flatMap { $0.slugifiedTags }
83+
return Array(Set(slugs)).sorted()
84+
}
85+
86+
/// Get all items in the collection with a certain tag.
87+
func withTag(_ tag: String) -> [Element] {
88+
filter { $0.hasTag(tag) }
89+
}
90+
}

Sources/TagKit/Views/TagCapsule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// TagKit
44
//
55
// Created by Daniel Saidi on 2022-08-19.
6-
// Copyright © 2022-2024 Daniel Saidi. All rights reserved.
6+
// Copyright © 2022-2025 Daniel Saidi. All rights reserved.
77
//
88

99
import SwiftUI

Sources/TagKit/Views/TagCapsuleStyle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// TagKit
44
//
55
// Created by Daniel Saidi on 2022-09-07.
6-
// Copyright © 2022-2024 Daniel Saidi. All rights reserved.
6+
// Copyright © 2022-2025 Daniel Saidi. All rights reserved.
77
//
88

99
import SwiftUI

Sources/TagKit/Views/TagEditList.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// TagKit
44
//
55
// Created by Daniel Saidi on 2022-08-19.
6-
// Copyright © 2022-2024 Daniel Saidi. All rights reserved.
6+
// Copyright © 2022-2025 Daniel Saidi. All rights reserved.
77
//
88

99
import SwiftUI

Sources/TagKit/Views/TagList.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Based on https://github.com/globulus/swiftui-flow-layout
66
//
77
// Created by Daniel Saidi on 2022-08-18.
8-
// Copyright © 2022-2024 Daniel Saidi. All rights reserved.
8+
// Copyright © 2022-2025 Daniel Saidi. All rights reserved.
99
//
1010

1111
import SwiftUI

0 commit comments

Comments
 (0)