Skip to content

Commit

Permalink
feat(@galactiks/explorer): explore places new content type
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelgautier committed Sep 26, 2023
1 parent 7b41e4a commit eaadfa2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const getWebPageDocuments = async (): Promise<Content[]> => {
documents: new Array<ContentlayerWebPageDocument>()
.concat(generated.allPages)
.concat(generated.allArticles)
.concat(generated.allPeople),
.concat(generated.allPeople)
.concat(generated.allPlaces),
people: generated.allPeople,
});

Expand Down
20 changes: 20 additions & 0 deletions packages/explorer/src/core/content/types/_schemas.mts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ const itemListSchema = thingSchema.extend({
),
});

// Schema: https://schema.org/PostalAddress
export const postalAddressSchema = thingSchema.extend({
addressCountry: z.string(),
addressLocality: z.string().optional(),
addressRegion: z.string().optional(),
postOfficeBoxNumber: z.string().optional(),
postalCode: z.string().optional(),
streetAddress: z.string().optional(),
});

// Schema: https://schema.org/Person
export const personSchema = thingSchema.extend({
additionalName: z.string().optional(),
Expand All @@ -95,6 +105,15 @@ export const personSchema = thingSchema.extend({
telephone: z.string().optional(),
});

// Schema: https://schema.org/Place
export const placeSchema = thingSchema.extend({
address: postalAddressSchema.optional(),
latitude: z.string().or(z.number()).optional(),
longitude: z.string().or(z.number()).optional(),
keywords: z.array(z.string()).optional(),
telephone: z.string().optional(),
});

// Schema: https://schema.org/CreativeWork
const creativeWorkSchema = thingSchema.extend({
url: z.string(),
Expand Down Expand Up @@ -189,6 +208,7 @@ export const pageSchema = galactiksSchema.merge(webPageSchema);
export type MetadataHeaders = z.infer<typeof metadataHeaders>;
export type ItemList = z.infer<typeof itemListSchema>;
export type Person = z.infer<typeof personSchema>;
export type Place = z.infer<typeof placeSchema>;
export type Organization = z.infer<typeof organizationSchema>;
export type Article = z.infer<typeof articlePageSchema>;
export type Page = z.infer<typeof pageSchema>;
3 changes: 3 additions & 0 deletions packages/explorer/src/core/content/types/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
Article as ContentlayerArticle,
Page as ContentlayerPage,
Person as ContentlayerPerson,
Place as ContentlayerPlace,
} from '@galactiks/contentlayer';

import type { MetadataHeaders, Page } from './_schemas.mjs';
Expand All @@ -16,6 +17,7 @@ export type {
DocumentTypes as ContentlayerDocumentTypes,
DataExports as ContentlayerDataExports,
Person as ContentlayerPerson,
Place as ContentlayerPlace,
Website as ContentlayerWebsite,
WebPageElement as ContentlayerWebPageElement,
} from '@galactiks/contentlayer';
Expand All @@ -25,4 +27,5 @@ export type ContentlayerWebPageDocument =
| ContentlayerArticle
| ContentlayerPage
| ContentlayerPerson
| ContentlayerPlace
| ContentlayerTagPage;

0 comments on commit eaadfa2

Please sign in to comment.