@miragon/slidev-validator 0.3.0 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miragon/slidev-validator",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "The Miragon Slidev deck validator: a configurable design-system linter (stable rule IDs, off/warn/error severities, extends/overrides/exceptions) shipped as a versioned CLI so central guardrail improvements reach decks over npm instead of a frozen copy.",
6
6
  "keywords": [
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module'
3
3
  import { pathToFileURL } from 'node:url'
4
4
  import { dirname, join } from 'node:path'
5
5
  import { parseSync } from '@slidev/parser'
6
- import { repoRoot, toRel } from '../../helpers.mjs'
6
+ import { repoRoot, deckDir, toRel } from '../../helpers.mjs'
7
7
 
8
8
  /**
9
9
  * The theme's layout archetypes live one-.vue-file-per-layout under the toolkit's
@@ -29,12 +29,23 @@ function layoutsDir() {
29
29
  */
30
30
  const BUILTIN_LAYOUTS = ['default']
31
31
 
32
+ /**
33
+ * Custom layouts a deck legitimately defines under its OWN `deck/layouts/`. Slidev
34
+ * natively resolves these (relative to the entry `deck/slides.md`), so a deck adding
35
+ * an on-brand archetype there is using a real, working layout — not a freehand
36
+ * drift. Guarded by `existsSync`: the flat reference deck has no `deck/layouts/`.
37
+ */
38
+ function deckLocalLayoutsDir() {
39
+ return join(deckDir(), 'layouts')
40
+ }
41
+
32
42
  function sanctionedLayouts() {
33
43
  const names = new Set(BUILTIN_LAYOUTS)
34
- const dir = layoutsDir()
35
- if (existsSync(dir)) {
36
- for (const f of readdirSync(dir)) {
37
- if (f.endsWith('.vue')) names.add(f.slice(0, -'.vue'.length))
44
+ for (const dir of [layoutsDir(), deckLocalLayoutsDir()]) {
45
+ if (existsSync(dir)) {
46
+ for (const f of readdirSync(dir)) {
47
+ if (f.endsWith('.vue')) names.add(f.slice(0, -'.vue'.length))
48
+ }
38
49
  }
39
50
  }
40
51
  return names
@@ -52,8 +63,9 @@ function slideFrontmatters(file) {
52
63
  /**
53
64
  * Consistency guardrail: every slide must opt into a layout archetype, so no slide
54
65
  * silently falls back to a freehand/default rendering that drifts off the design
55
- * system. The allowed set is DERIVED from the installed toolkit's `layouts/*.vue`
56
- * (never hardcoded), plus the built-in `default`. `src:` import stubs are exempt.
66
+ * system. The allowed set is DERIVED (never hardcoded) from the installed toolkit's
67
+ * `layouts/*.vue` AND any deck-local `deck/layouts/*.vue` (which Slidev natively
68
+ * supports), plus the built-in `default`. `src:` import stubs are exempt.
57
69
  */
58
70
  export const sanctionedLayout = {
59
71
  id: 'sanctioned-layout',