@kolkrabbi/kol-framework 0.58.0 → 0.59.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": "@kolkrabbi/kol-framework",
3
- "version": "0.58.0",
3
+ "version": "0.59.0",
4
4
  "description": "Site shell and page layout",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,9 +23,9 @@
23
23
  "react-router-dom": "^6.0.0 || ^7.0.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@kolkrabbi/kol-component": "^0.307.0",
27
26
  "@kolkrabbi/kol-markdown": "0.2.0",
28
- "@kolkrabbi/kol-icons": "^0.48.0"
27
+ "@kolkrabbi/kol-component": "^0.307.0",
28
+ "@kolkrabbi/kol-icons": "^0.49.0"
29
29
  },
30
30
  "files": [
31
31
  "src",
@@ -0,0 +1,27 @@
1
+ import { kindOf, extOf } from '@kolkrabbi/kol-component'
2
+
3
+ /* DOCUMENT FILES — the files beside a folder's markdown (DocumentIndexFilesAndIcons049, kol-website 2026-10-28, a point
4
+ * of the MarkdownPage ticket: *"a folder may also hold PDFs and images; the contents index lists them beside the md
5
+ * pages and opens them in the DS QuickLook, not as pages"*). The consumer globs them as URLs and hands the modules over:
6
+ *
7
+ * documentFiles(import.meta.glob('./brand/business/**\/*.{pdf,png,jpg,jpeg,webp,svg}', { query: '?url', import: 'default', eager: true }))
8
+ * → [{ id, title, group, file, ext, kind }] in the glob's (path) order
9
+ *
10
+ * id the file's stem without a `NN-` prefix (`02-business-plan.pdf` → `business-plan`)
11
+ * title the stem, unprefixed and titlecased (`Business Plan`)
12
+ * group the file's parent folder, titlecased and unprefixed (`frumkvaedi-2024/` → `Frumkvaedi 2024`); '' at the root
13
+ * file the served URL; ext its extension; kind the DS's (`kindOf`: pdf · image · video · audio · …)
14
+ *
15
+ * A row is what `DocumentIndex` draws as a card in its part and opens in Quick Look. `documentTabs` is the markdown half. */
16
+ const unprefix = (s) => s.replace(/^\d+[-_.]\s*/, '')
17
+ const titleCase = (s) => s.replace(/[-_]+/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
18
+
19
+ export default function documentFiles(modules = {}, { root = '' } = {}) {
20
+ return Object.entries(modules).map(([path, url]) => {
21
+ const rel = root && path.startsWith(root) ? path.slice(root.length) : path
22
+ const parts = rel.replace(/^\.?\//, '').split('/')
23
+ const name = parts.pop()
24
+ const stem = name.replace(/\.[a-z0-9]+$/i, '')
25
+ return { id: unprefix(stem), title: titleCase(unprefix(stem)), group: parts.length ? titleCase(unprefix(parts[parts.length - 1])) : '', file: typeof url === 'string' ? url : '', ext: extOf(name), kind: kindOf({ key: name }) }
26
+ })
27
+ }
package/src/index.js CHANGED
@@ -32,3 +32,4 @@ export { default as CategoryPage } from './CategoryPage.jsx'
32
32
  export { default as MarkdownPage } from './MarkdownPage.jsx'
33
33
  export { default as LinkPreview } from './LinkPreview.jsx'
34
34
  export { default as documentTabs } from './documentTabs.js'
35
+ export { default as documentFiles } from './documentFiles.js'