@pitlane/content 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,22 @@
1
1
  # @pitlane/content
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 87ec1f6: Give headings the ids GitHub gives them. `headings()` now lowercases a heading, removes every character outside letters, marks, digits, and connector punctuation, and turns each space into a hyphen without collapsing or trimming any of them — the algorithm GitHub uses, and the one Astro's `rehype-heading-ids` uses through the same `github-slugger` package. `## Databases & Data Loading` was `databases-data-loading` and is now `databases--data-loading`; `## Jenni’s Quesadillas` was `jenni-s-quesadillas` and is now `jennis-quesadillas`.
8
+
9
+ A heading containing punctuation or symbols can therefore get a different `id` than it did before — `## Hello World!` keeps `hello-world`, but `## Databases & Data Loading` does not — so an anchor written by hand against the old ids needs checking once. In exchange, a table of contents carried over from GitHub or Astro keeps landing without being rewritten. A heading that slugs to nothing at all, such as `## 🎉`, still falls back to `heading` rather than to the empty `id` GitHub produces, and a later `## Heading` in the same document then takes `heading-1`.
10
+
11
+ ### Patch Changes
12
+
13
+ - f8b0db5: Keep content prebuilds from deleting the running app's optimized browser dependencies. This fixes `504 (Outdated Optimize Dep)` errors that could leave MDX updates and client-side navigation broken until the dev server restarted.
14
+ - 98e8a77: Vite no longer warns that it cannot analyze a dynamic import in `@pitlane/content` when an app using `contentLayer()` starts its dev server. The runtime import of a document's resolved dependencies is now marked `/* @vite-ignore */`, since its target is only known at request time.
15
+
3
16
  ## 0.1.1
4
17
 
18
+ Published 2026-09-21. [npm](https://www.npmjs.com/package/@pitlane/content/v/0.1.1) · [GitHub release](https://github.com/pitlane-tools/pitlane/releases/tag/%40pitlane/content%400.1.1) · [Source](https://github.com/pitlane-tools/pitlane/commit/b725843491ad0c36c61c83d44466134f76dbd615).
19
+
5
20
  Documentation only. No code changed.
6
21
 
7
22
  - The npm description is one line now: "Schema-validated content collections for Remix." The old one led with `createContent()` and ran well past what a registry listing shows.
@@ -11,11 +26,18 @@ Documentation only. No code changed.
11
26
 
12
27
  ## 0.1.0
13
28
 
29
+ Published 2026-09-21. [npm](https://www.npmjs.com/package/@pitlane/content/v/0.1.0) · [GitHub release](https://github.com/pitlane-tools/pitlane/releases/tag/%40pitlane/content%400.1.0) · [Source](https://github.com/pitlane-tools/pitlane/commit/31aae9c3c941238fbb94769e578e320179dc8284).
30
+
14
31
  Initial release.
15
32
 
16
33
  - `createContent` returns typed collection handles synchronously without loading entries. Reads and rendering remain asynchronous; declaration errors throw synchronously.
34
+ - An entry's data is validated against its collection's schema as it loads, before any query returns it. Any Standard Schema validator does that work, `remix/data-schema` and Zod included, and the entry type is inferred from the schema rather than generated: `CollectionEntry<typeof content.blog>` names one. A failure reports the entry, the collection, the file it came from, and every issue.
17
35
  - `getCollection`, `getCollection(filter)`, and `getEntry` over entries sorted by id; `c.reference(collection)` for typed pointers between collections.
18
36
  - `render()` resolves an entry's Markdown or MDX to a Remix component and its heading list, parsing nothing until it is called.
19
- - Two loader interfaces: `ContentLoader` resolves a whole collection in one execution and can be prebuilt, `LiveLoader` answers one query at a time and runs on every read. `loaders.glob` and `loaders.file` implement the first.
37
+ - Without a bundler, `render()` also resolves an MDX document's own imports relative to the document. A namespace import and `import.meta` are refused by name, since neither survives the function body an MDX document compiles to here.
38
+ - Two loader interfaces: `ContentLoader` resolves a whole collection in one execution and can be prebuilt, `LiveLoader` answers one query at a time and runs on every read. `loaders.glob` and `loaders.file` implement the first. `glob` reads Markdown, MDX, JSON, and YAML, one entry per file; `file` reads a single JSON or YAML file holding many entries, and takes a `parser` for any other format.
20
39
  - `contentLayer()` from `@pitlane/content/vite` loads `ContentLoader` collections after evaluating their declarations and inlines them into the bundle. It waits for loading and validation before emitting, and watches the loaders' sources in dev.
21
- - `headings()` from `@pitlane/content/satteri` produces the heading list on both rendering paths.
40
+ - `headings()` from `@pitlane/content/satteri` produces the heading list on both rendering paths. `rawStyles()` sits beside it and hands a `<style>` element's CSS to Remix as markup, which is what keeps an Expressive Code theme from reaching the page escaped into rules that match nothing. `render()` applies both; a Vite build passes them to `vite-plugin-satteri`.
41
+ - `hotContent()` from `@pitlane/content/hot` reloads the browser when a file behind a collection changes, for an application that runs from source with no build. It does nothing unless `remix/node-hmr` is supervising the process, so it can stay in production code. A file created after startup still needs a restart.
42
+ - Every peer dependency is optional, `remix` included. Reading and validating data imports neither it nor `satteri`; `render()` loads Remix only when something asks for a component, and names the entry that needed it if Remix is not installed. Node `^20.19.0 || >=22.12.0`.
43
+ - The prebuild channel, the manifest emitter, and the MDX import reader ship as `@pitlane/content/internal/prebuild`, `/internal/codegen`, and `/internal/mdx`, so a plugin for a bundler other than Vite can reuse them.
package/dist/index.mjs CHANGED
@@ -280,7 +280,7 @@ function view(collection, entry) {
280
280
  data: entry.data,
281
281
  ...entry.filePath === void 0 ? {} : { filePath: entry.filePath },
282
282
  render: async () => {
283
- return await (await import("./render-U9dXN6f0.mjs").catch((cause) => {
283
+ return await (await import("./render-Bg0i1C_C.mjs").catch((cause) => {
284
284
  throw missingRenderer(`${collection}/${entry.id}`, cause) ?? cause;
285
285
  })).renderedEntry(collection, entry);
286
286
  }
@@ -222,7 +222,14 @@ async function nodeResolution() {
222
222
  async function importFrom(specifier, from, where, node, attributes) {
223
223
  let resolved = specifier.startsWith(".") ? new URL(specifier, from).href : resolveBare(specifier, from, where, node);
224
224
  try {
225
- return await (attributes ? import(resolved, { with: attributes }) : import(resolved));
225
+ return await (attributes ? import(
226
+ /* @vite-ignore */
227
+ resolved,
228
+ { with: attributes }
229
+ ) : import(
230
+ /* @vite-ignore */
231
+ resolved
232
+ ));
226
233
  } catch (error) {
227
234
  let cause = error instanceof Error ? error.message : String(error);
228
235
  throw new Error(`"${where}" imports "${specifier}", which could not be loaded: ${cause}`, { cause: error });
package/dist/satteri.mjs CHANGED
@@ -1,19 +1,40 @@
1
1
  //#region src/satteri.ts
2
2
  /**
3
- * The base slug for a heading with no letters or digits at all (`## ---`). An
4
- * empty `id` is invalid HTML and makes the anchor a bare `#`, which lands
5
- * nowhere; a fixed word plus the usual collision suffix keeps such headings
6
- * addressable and distinct.
3
+ * The base slug for a heading that slugs to nothing at all, such as `## ***` or
4
+ * `## 🎉`. GitHub answers the empty string there; an empty `id` is invalid HTML
5
+ * and makes the anchor a bare `#`, which lands nowhere, so a fixed word plus
6
+ * the usual collision suffix keeps such headings addressable and distinct. This
7
+ * is the one case where these slugs are deliberately not GitHub's.
7
8
  */
8
9
  const FALLBACK_SLUG = "heading";
9
10
  /**
10
- * The slug for `text`, kept distinct from every slug `taken` already holds by
11
+ * Every character GitHub's slugger removes: anything that is not alphabetic, a
12
+ * combining mark, a decimal digit, connector punctuation, a space, or a hyphen.
13
+ * Marks are kept because dropping them would shatter Devanagari, Hebrew, and
14
+ * Arabic words into bare consonants; letters of every script are kept so a
15
+ * Japanese or Cyrillic heading slugs to its own text rather than to nothing.
16
+ *
17
+ * `github-slugger` ships this set as a table generated from Unicode 13, while a
18
+ * regular expression matches against whatever Unicode version the engine
19
+ * carries. A character assigned after Unicode 13 therefore survives here and
20
+ * would be stripped there; nothing assigned in Unicode 13 or earlier differs.
21
+ */
22
+ const STRIPPED = /[^\p{Alphabetic}\p{M}\p{Nd}\p{Pc} -]/gu;
23
+ /**
24
+ * The slug for `text`, built the way GitHub builds a heading's `id`: lowercase
25
+ * it, remove every stripped character, then turn each remaining space into a
26
+ * hyphen. Nothing is collapsed and nothing is trimmed, so `Databases & Data
27
+ * Loading` slugs to `databases--data-loading` and `## ---` to `---`. Astro slugs
28
+ * with the same algorithm, so a table of contents written by hand against
29
+ * either of them keeps landing after a move to Pitlane.
30
+ *
31
+ * The result is then kept distinct from every slug `taken` already holds by
11
32
  * suffixing `-1`, `-2`, … The map remembers the last suffix tried for a base so
12
33
  * a document of a hundred identical headings stays linear, and the loop covers
13
34
  * the case where the suffixed candidate is itself a real heading's slug.
14
35
  */
15
36
  function uniqueSlug(text, taken) {
16
- let base = text.toLowerCase().replace(/[^\p{L}\p{N}\p{M}]+/gu, "-").replace(/^-+|-+$/g, "");
37
+ let base = text.toLowerCase().replace(STRIPPED, "").replaceAll(" ", "-");
17
38
  if (!base) base = FALLBACK_SLUG;
18
39
  let suffix = taken.get(base) ?? 0;
19
40
  let slug = base;
package/dist/vite.mjs CHANGED
@@ -225,6 +225,7 @@ async function inPrebuildServer(root, entry, resolution, onWatched) {
225
225
  root,
226
226
  configFile: false,
227
227
  logLevel: "silent",
228
+ optimizeDeps: { noDiscovery: true },
228
229
  resolve: resolution,
229
230
  server: {
230
231
  middlewareMode: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pitlane/content",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Schema-validated content collections for Remix.",
5
5
  "keywords": [
6
6
  "content",