Skip to content

Commit 077abd9

Browse files
committed
hackish use of schema
1 parent 52eabb5 commit 077abd9

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

apps/website/app/utils/conversion/jsonld.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ type Content = Tables<"Content">;
66
type Space = Tables<"Space">;
77
type PlatformAccount = Tables<"PlatformAccount">;
88

9+
// This is a temporary hack
10+
const KnownSchemaEntities: Record<string, string[]> = {
11+
Claim: ["dg"],
12+
Evidence: ["dg"],
13+
Question: ["dg"],
14+
SourceDocument: ["dg"],
15+
describesActivity: ["dg"],
16+
observationStatement: ["dg"],
17+
observationOriginActivity: ["dg"],
18+
observationBase: ["dg"],
19+
sourceDocument: ["dg"],
20+
opposes: ["dg"],
21+
opposedBy: ["dg"],
22+
supports: ["dg"],
23+
supportedBy: ["dg"],
24+
addresses: ["dg"],
25+
addressedBy: ["dg"],
26+
};
27+
928
export const asJsonLD = async ({
1029
space,
1130
concept,
@@ -31,7 +50,7 @@ export const asJsonLD = async ({
3150
if (MIMETYPES[targetFormat] === undefined) {
3251
targetFormat = "html";
3352
}
34-
const schemaUrl = concept.schema_id
53+
let schemaUrl: string | string[] = concept.schema_id
3554
? "sdata:" + concept.schema_id
3655
: concept.arity === 2
3756
? "RelationDef"
@@ -55,6 +74,10 @@ export const asJsonLD = async ({
5574
if (val && typeof val === "number") extraData[role] = `sdata:${val}`;
5675
}
5776
}
77+
const knownSchemas = KnownSchemaEntities[schema?.name ?? ""];
78+
if (schema !== undefined && knownSchemas !== undefined) {
79+
schemaUrl = [schemaUrl, ...knownSchemas.map((s) => `${s}:${schema.name}`)];
80+
}
5881
// Explicit punning
5982
if (concept.is_schema && concept.arity === 2) {
6083
extraData["subClassOf"] = [

0 commit comments

Comments
 (0)