Project updates from Template #1

Merged
javier merged 123 commits from project/update-from-template into main 2026-09-04 13:40:36 +00:00
3 changed files with 12 additions and 3 deletions
Showing only changes of commit c64c8b726d - Show all commits
@@ -49,6 +49,7 @@ public extension StructuredData {
/// - alternateName: the name the organization is also known by, or `nil` (the default) to omit its property. /// - alternateName: the name the organization is also known by, or `nil` (the default) to omit its property.
/// - description: what the organization does, or `nil` (the default) to omit its property. /// - description: what the organization does, or `nil` (the default) to omit its property.
/// - areaServed: the area the organization serves, or `nil` (the default) to omit its property. /// - areaServed: the area the organization serves, or `nil` (the default) to omit its property.
/// - email: the address the organization is written to, or `nil` (the default) to omit its property.
/// - logo: the absolute URL of the organization's logo, or `nil` (the default) to omit its property. /// - logo: the absolute URL of the organization's logo, or `nil` (the default) to omit its property.
/// - profiles: the absolute URLs of the organization's public profiles, or empty (the default) to omit their property. /// - profiles: the absolute URLs of the organization's public profiles, or empty (the default) to omit their property.
init( init(
@@ -57,6 +58,7 @@ public extension StructuredData {
alternateName: String? = nil, alternateName: String? = nil,
description: String? = nil, description: String? = nil,
areaServed: String? = nil, areaServed: String? = nil,
email: String? = nil,
logo: String? = nil, logo: String? = nil,
profiles: [String] = [] profiles: [String] = []
) { ) {
@@ -79,6 +81,10 @@ public extension StructuredData {
organization.append(.init(.areaServed, value: .string(areaServed))) organization.append(.init(.areaServed, value: .string(areaServed)))
} }
if let email {
organization.append(.init(.email, value: .string(email)))
}
if let logo { if let logo {
organization.append(.init(.logo, value:.string(logo))) organization.append(.init(.logo, value:.string(logo)))
} }
@@ -75,6 +75,8 @@ public extension StructuredData.Property.Name {
static let areaServed: Self = "areaServed" static let areaServed: Self = "areaServed"
/// What the thing a node describes is or does. /// What the thing a node describes is or does.
static let description: Self = "description" static let description: Self = "description"
/// The address the thing a node describes is written to.
static let email: Self = "email"
/// The absolute URL of an organization's logo. /// The absolute URL of an organization's logo.
static let logo: Self = "logo" static let logo: Self = "logo"
/// The name of the thing a node describes. /// The name of the thing a node describes.
@@ -31,17 +31,18 @@ struct StructuredDataTests {
} }
@Test @Test
func `carries the organization's alternate name, description, and area in that order`() { func `carries the organization's alternate name, description, area, and address in that order`() {
let data = StructuredData( let data = StructuredData(
name: "A Site", name: "A Site",
url: "https://site.example/", url: "https://site.example/",
alternateName: "The Site", alternateName: "The Site",
description: "What the site is.", description: "What the site is.",
areaServed: "A City" areaServed: "A City",
email: "hello@site.example"
) )
#expect(data.payload.contains( #expect(data.payload.contains(
#""name":"A Site","url":"https://site.example/","alternateName":"The Site","description":"What the site is.","areaServed":"A City""# #""name":"A Site","url":"https://site.example/","alternateName":"The Site","description":"What the site is.","areaServed":"A City","email":"hello@site.example""#
)) ))
} }