@_linked/schema

中文文档
1.9.2发布于 2026/10/28MIT AND CC-BY-SA-3.0TypeScriptES Module构建来源已验证近 30 天下载 4360

schema.org for Linked: its vocabulary as Turtle, an accessor for every term, and shapes for the classes Linked apps use. The package mirrors schema.org and holds only its terms ([vocabulary rules](https://github.com/linked-fw/schema/

原始使用文档
文档目录4 节
  1. Terms
  2. The data
  3. Development
  4. Data license

@_linked/schema

schema.org for Linked: its vocabulary as Turtle, an accessor for every term, and shapes for the classes Linked apps use. The package mirrors schema.org and holds only its terms (vocabulary rules).

Terms

Import the terms module as a namespace:

import * as schema from '@_linked/schema/ontologies/schema';

static targetClass = schema.Person; // {id: 'http://schema.org/Person'}

ontologies/schema exports one named term for each of schema.org's 3,023 subjects, and nothing else. A namespace import is the one way to use them:

  • It reads like the Turtle. schema.Person is schema:Person, and the prefix says which vocabulary a term comes from, also where several are used side by side (schema.name, rdfs.label).
  • It tree-shakes. Every term is a /*#__PURE__*/ named export, so a bundler keeps only the terms a module uses. On the 2,802-term release, cli report 027 measured a 402,091-byte module and, with esbuild (minified), a 125,759-byte bundle when every term is kept, against 1,868 bytes for schema.Person alone: 18 bytes more than a bundle with no terms (1,850). An aggregated object would keep them all.

Names are generated, one rule for all: a character that cannot appear in an identifier becomes _, a leading digit gets a leading _ (schema:3DModel → schema._3DModel), and a reserved word gets a trailing _ (schema:yield → schema.yield_). There are no aliases.

ns, dataFiles, loadData() and _ontologyResource are in @_linked/schema/ontologies/schema.data:

import {ns} from '@_linked/schema/ontologies/schema.data';

Importing the package root (@_linked/schema) or shapes/index registers the ontology, which keeps every term; import ontologies/schema directly where bundle size matters.

How to use terms from any vocabulary, and when {id} is still right, is in core's README: Using ontology terms.

The data

src/data/schema.ttl is schema.org's latest release, version 30.1, https://schema.org/version/30.1/schemaorg-current-https.nt, written as Turtle by scripts/write-turtle.mjs and otherwise unchanged; a leading comment names the source. The namespace is http://schema.org/, not schema.org's preferred https://schema.org/: tools like jsonld convert every schema.org IRI to http, so the writer rewrites https on import (except schema:isPartOf objects, kept as published). Every other file uses http too. To refresh the data from a schema.org release: backlog 002.

The official files are the only source of the package's terms: the package never adds a class or property to a standard's namespace. What the published standard lacks, mainly metadata, goes in one extra file per prefix, src/data/<prefix>-added.ttl, listed in "linkedOntologies"' data:

  • the ontology entity itself: owl:Ontology, title, description, vann:preferredNamespacePrefix, vann:preferredNamespaceUri, the source URL and version;
  • annotations on terms the standard already defines, such as a missing rdfs:label.

New classes or properties never go there; a term a standard lacks belongs in the consumer's own ontology package.

schema.org's data does not describe the namespace itself, so src/data/schema-added.ttl holds the ontology entity: schema: as an owl:Ontology, its title, description and label, the preferred prefix and namespace, and the source and version.

linked generate-ontology writes the three modules in src/ontologies/ from the data (package.json "linkedOntologies"); linked build fails when they are out of date. Never edit them by hand.

Development

npx linked build    # checks the ontology modules, compiles, writes lib/esm/data/shapes.ttl
npm test            # runs against lib/

Data license

The package code is MIT licensed (see LICENSE). The bundled ontology data is derived from the schema.org vocabulary (https://schema.org), (c) the schema.org Sponsors and is not covered by the MIT license: it remains under the Creative Commons Attribution-ShareAlike 3.0 (CC BY-SA 3.0), https://creativecommons.org/licenses/by-sa/3.0/. See NOTICE.

版本与发布记录

@_linked/schema 共发布 35 个版本,首次发布于 2026/04/23;过去 12 个月发布了 35 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.9.2latest2026/10/2810 天前
1.9.12026/10/2513 天前
1.9.02026/10/2513 天前
1.8.22026/10/2513 天前
1.8.12026/10/2514 天前
1.8.02026/10/2414 天前

关于 @_linked/schema 的常见问题

@_linked/schema 是什么?

schema.org for Linked: its vocabulary as Turtle, an accessor for every term, and shapes for the classes Linked apps use. The package mirrors schema.org and holds only its terms ([vocabulary rules](https://github.com/linked-fw/schema/

如何安装 @_linked/schema?

在项目目录运行 npm install @_linked/schema,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.2.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@_linked/schema 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@_linked/schema 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@_linked/schema 可以商用吗?

@_linked/schema 使用 MIT AND CC-BY-SA-3.0 许可。声明的许可为 MIT AND CC-BY-SA-3.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@_linked/schema 的下载量有多少?

根据 npm 官方下载统计,@_linked/schema 在 2026/10/05 – 2026/11/03 这 30 天内被下载 4,360 次,日均约 145 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@_linked/schema 还在维护吗?

最新版本 1.9.2 发布于 2026/10/28(10 天前);至今共发布 35 个版本,其中过去 12 个月发布了 35 个;首次发布于 2026/04/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。