11---
22import type { Lesson } from " ../lib/lessons" ;
3+ import { isCreatedByUs , CREATOR_ORG } from " ../lib/provenance" ;
34import { getCollection } from " astro:content" ;
45
56interface Props {
@@ -8,6 +9,7 @@ interface Props {
89}
910
1011const { lesson, canonicalUrl } = Astro .props as Props ;
12+ const createdByUs = isCreatedByUs (lesson );
1113
1214const pathways = await getCollection (" pathways" );
1315const pathwayMap = Object .fromEntries (pathways .map ((p ) => [p .id , p .data .name ]));
@@ -37,11 +39,32 @@ if (nonEmpty(lesson.license)) data.license = lesson.license;
3739if (nonEmpty (lesson .author )) data .author = { " @type" : " Person" , name: lesson .author };
3840if (nonEmpty (lesson .learningObjectives )) data .teaches = lesson .learningObjectives ;
3941
42+ // Provenance: we always publish the structured data (sdPublisher). For curated
43+ // external resources, point sameAs at the canonical source and credit the
44+ // source provider as publisher; for resources we created, we are the publisher.
45+ data .sdPublisher = { " @type" : " Organization" , name: CREATOR_ORG };
46+ if (createdByUs ) {
47+ data .publisher = { " @type" : " Organization" , name: CREATOR_ORG };
48+ } else {
49+ if (nonEmpty (lesson .url )) data .sameAs = lesson .url ;
50+ if (nonEmpty (lesson .provider )) data .publisher = { " @type" : " Organization" , name: lesson .provider };
51+ }
52+
53+ // Intended educational role (schema.org): guides are for self-study (student);
54+ // taught formats serve both learners and instructors.
55+ const taught = [" workshop" , " course" ].includes ((lesson .learningResourceType ?? " " ).toLowerCase ());
56+ const educationalAudience = [
57+ { " @type" : " EducationalAudience" , educationalRole: " student" },
58+ ... (taught ? [{ " @type" : " EducationalAudience" , educationalRole: " teacher" }] : []),
59+ ];
60+
4061if (lesson .roles .length > 0 ) {
41- data .audience = lesson .roles .map ((role ) => ({
42- " @type" : " Audience" ,
43- audienceType: role ,
44- }));
62+ data .audience = [
63+ ... educationalAudience ,
64+ ... lesson .roles .map ((role ) => ({ " @type" : " Audience" , audienceType: role })),
65+ ];
66+ } else {
67+ data .audience = educationalAudience ;
4568}
4669
4770if (lesson .pathways .length > 0 ) {
0 commit comments