Added the email property to the organization structured data in the Infrastructure package target.
This commit is contained in:
@@ -49,6 +49,7 @@ public extension StructuredData {
|
||||
/// - 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.
|
||||
/// - 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.
|
||||
/// - profiles: the absolute URLs of the organization's public profiles, or empty (the default) to omit their property.
|
||||
init(
|
||||
@@ -57,6 +58,7 @@ public extension StructuredData {
|
||||
alternateName: String? = nil,
|
||||
description: String? = nil,
|
||||
areaServed: String? = nil,
|
||||
email: String? = nil,
|
||||
logo: String? = nil,
|
||||
profiles: [String] = []
|
||||
) {
|
||||
@@ -79,6 +81,10 @@ public extension StructuredData {
|
||||
organization.append(.init(.areaServed, value: .string(areaServed)))
|
||||
}
|
||||
|
||||
if let email {
|
||||
organization.append(.init(.email, value: .string(email)))
|
||||
}
|
||||
|
||||
if let logo {
|
||||
organization.append(.init(.logo, value:.string(logo)))
|
||||
}
|
||||
|
||||
+2
@@ -75,6 +75,8 @@ public extension StructuredData.Property.Name {
|
||||
static let areaServed: Self = "areaServed"
|
||||
/// What the thing a node describes is or does.
|
||||
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.
|
||||
static let logo: Self = "logo"
|
||||
/// The name of the thing a node describes.
|
||||
|
||||
@@ -31,17 +31,18 @@ struct StructuredDataTests {
|
||||
}
|
||||
|
||||
@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(
|
||||
name: "A Site",
|
||||
url: "https://site.example/",
|
||||
alternateName: "The Site",
|
||||
description: "What the site is.",
|
||||
areaServed: "A City"
|
||||
areaServed: "A City",
|
||||
email: "hello@site.example"
|
||||
)
|
||||
|
||||
#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""#
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user