Function
A single application/ld+json script element
This exists for the escaping. Course titles and descriptions are
author-controlled text, and a description containing </script> would
otherwise close the tag early and turn everything after it into live markup.
Serializing in one place — rather than interpolating a template literal on
four pages — means that is handled once.
< is escaped to its unicode form, which JSON parsers read identically and
an HTML parser does not treat as the start of a tag. That is the standard
defence for JSON embedded in a document.
No library. schema.org objects are plain JSON; a dependency here would earn nothing.
Renders one schema.org payload as linked data.