@quartz-community/bases-page 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 +27 -0
- package/LICENSE +21 -0
- package/README.md +315 -0
- package/dist/BasesBody-B4CEJjEp.d.ts +6 -0
- package/dist/chunk-2AUMER56.js +44 -0
- package/dist/chunk-2AUMER56.js.map +1 -0
- package/dist/chunk-4HXXKSJ4.js +929 -0
- package/dist/chunk-4HXXKSJ4.js.map +1 -0
- package/dist/chunk-TDUJOYTU.js +42 -0
- package/dist/chunk-TDUJOYTU.js.map +1 -0
- package/dist/chunk-X2AZ5GOJ.js +1931 -0
- package/dist/chunk-X2AZ5GOJ.js.map +1 -0
- package/dist/compiler/index.d.ts +146 -0
- package/dist/compiler/index.js +7 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/components/index.d.ts +13 -0
- package/dist/components/index.js +9 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +18703 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +48 -0
- package/dist/registry.js +7 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +181 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +143 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ViewRenderer, ViewTypeRegistration } from './types.js';
|
|
2
|
+
import 'preact';
|
|
3
|
+
import '@quartz-community/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Central registry for Bases view types.
|
|
7
|
+
*
|
|
8
|
+
* Built-in views (table, list, cards, gallery, board) are registered at plugin
|
|
9
|
+
* init time. Community plugins can register additional view types by importing
|
|
10
|
+
* this singleton and calling {@link viewRegistry.register}.
|
|
11
|
+
*
|
|
12
|
+
* @example Community plugin registering a custom view:
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { viewRegistry } from "@quartz-community/bases-page";
|
|
15
|
+
*
|
|
16
|
+
* viewRegistry.register({
|
|
17
|
+
* id: "timeline",
|
|
18
|
+
* name: "Timeline",
|
|
19
|
+
* icon: "git-branch",
|
|
20
|
+
* render: ({ entries, view }) => <div class="bases-timeline">...</div>,
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare class ViewRegistry {
|
|
25
|
+
private views;
|
|
26
|
+
/**
|
|
27
|
+
* Register a view type. If a view with the same ID already exists it is
|
|
28
|
+
* silently replaced — this lets config-level `customViews` override built-in
|
|
29
|
+
* renderers for the same type.
|
|
30
|
+
*/
|
|
31
|
+
register(registration: ViewTypeRegistration): void;
|
|
32
|
+
/** Look up a registered view type by ID. */
|
|
33
|
+
get(id: string): ViewTypeRegistration | undefined;
|
|
34
|
+
/** Return all registered view types (insertion order). */
|
|
35
|
+
getAll(): ViewTypeRegistration[];
|
|
36
|
+
/** Check whether a view type is registered. */
|
|
37
|
+
has(id: string): boolean;
|
|
38
|
+
/** Remove a view type registration. Returns true if it existed. */
|
|
39
|
+
unregister(id: string): boolean;
|
|
40
|
+
}
|
|
41
|
+
declare const viewRegistry: ViewRegistry;
|
|
42
|
+
/**
|
|
43
|
+
* Convenience: bulk-register views from a `customViews` config record.
|
|
44
|
+
* Called during plugin init to merge user-provided renderers into the registry.
|
|
45
|
+
*/
|
|
46
|
+
declare function registerCustomViews(customs: Record<string, ViewRenderer>): void;
|
|
47
|
+
|
|
48
|
+
export { registerCustomViews, viewRegistry };
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"registry.js"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { ComponentChild } from 'preact';
|
|
2
|
+
export { BuildCtx, FilePath, FullSlug, GlobalConfiguration, PageGenerator, PageMatcher, ProcessedContent, QuartzComponent, QuartzComponentConstructor, QuartzComponentProps, QuartzPageTypePlugin, QuartzPageTypePluginInstance, QuartzPluginData, VirtualPage } from '@quartz-community/types';
|
|
3
|
+
|
|
4
|
+
/** Props passed to every view renderer */
|
|
5
|
+
interface ViewRendererProps {
|
|
6
|
+
entries: BasesEntry[];
|
|
7
|
+
view: BasesView;
|
|
8
|
+
basesData: BasesData;
|
|
9
|
+
total: number;
|
|
10
|
+
locale: string;
|
|
11
|
+
/** Slug of the page rendering this view (for resolving relative paths) */
|
|
12
|
+
slug: string;
|
|
13
|
+
/** All known slugs in the site (for `transformLink` with `shortest` strategy) */
|
|
14
|
+
allSlugs: string[];
|
|
15
|
+
/** Link resolution strategy ("absolute" | "relative" | "shortest"). Passed from plugin options. */
|
|
16
|
+
linkResolution: "absolute" | "relative" | "shortest";
|
|
17
|
+
/** Plugin-level options from the view type registration, if any. */
|
|
18
|
+
options?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** View renderer function signature */
|
|
21
|
+
type ViewRenderer = (props: ViewRendererProps) => ComponentChild;
|
|
22
|
+
/** Registration record for a view type */
|
|
23
|
+
interface ViewTypeRegistration {
|
|
24
|
+
/** Unique view type identifier, e.g. "table", "board", "my-custom-view" */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Human-readable display name shown in the view selector */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Optional Lucide icon name */
|
|
29
|
+
icon?: string;
|
|
30
|
+
/** The render function producing Preact JSX */
|
|
31
|
+
render: ViewRenderer;
|
|
32
|
+
/**
|
|
33
|
+
* Optional CSS string injected once per page when this view type is active.
|
|
34
|
+
* Deduplicated by view type ID — only injected once even if multiple views
|
|
35
|
+
* of the same type appear on the page.
|
|
36
|
+
*/
|
|
37
|
+
css?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Optional client-side script injected once per page when this view type is
|
|
40
|
+
* active. Runs after the DOM is loaded, following the same lifecycle as
|
|
41
|
+
* `QuartzComponent.afterDOMLoaded`. Deduplicated by view type ID.
|
|
42
|
+
*/
|
|
43
|
+
afterDOMLoaded?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional user-supplied configuration for this view type. Community plugins
|
|
46
|
+
* can use this to accept plugin-level options (e.g. feature flags, CDN URLs)
|
|
47
|
+
* that are set once at registration time and passed through to every render
|
|
48
|
+
* invocation via `ViewRendererProps.options`.
|
|
49
|
+
*/
|
|
50
|
+
options?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/** Plugin options for BasesPage */
|
|
53
|
+
interface BasesPageOptions {
|
|
54
|
+
/** Default view type when none specified. Default: "table" */
|
|
55
|
+
defaultViewType?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Custom view renderers passed via TS config override.
|
|
58
|
+
* Keys are view type IDs. These are registered into the ViewRegistry
|
|
59
|
+
* at plugin init time, alongside (or overriding) built-in views.
|
|
60
|
+
*/
|
|
61
|
+
customViews?: Record<string, ViewRenderer>;
|
|
62
|
+
/**
|
|
63
|
+
* How to resolve internal links in view renderers. Should match the
|
|
64
|
+
* `markdownLinkResolution` setting of the crawl-links plugin.
|
|
65
|
+
* Default: "shortest"
|
|
66
|
+
*/
|
|
67
|
+
linkResolution?: "absolute" | "relative" | "shortest";
|
|
68
|
+
}
|
|
69
|
+
/** Sort direction */
|
|
70
|
+
type SortDirection = "ASC" | "DESC";
|
|
71
|
+
/** Sort entry — one column + direction pair */
|
|
72
|
+
interface SortEntry {
|
|
73
|
+
property: string;
|
|
74
|
+
direction?: SortDirection;
|
|
75
|
+
}
|
|
76
|
+
/** Filter tree node — recursive and/or/not structure matching Obsidian spec */
|
|
77
|
+
type FilterNode = string | {
|
|
78
|
+
and: FilterNode[];
|
|
79
|
+
} | {
|
|
80
|
+
or: FilterNode[];
|
|
81
|
+
} | {
|
|
82
|
+
not: FilterNode[];
|
|
83
|
+
};
|
|
84
|
+
/** Group-by configuration */
|
|
85
|
+
interface GroupBy {
|
|
86
|
+
property: string;
|
|
87
|
+
direction?: SortDirection;
|
|
88
|
+
}
|
|
89
|
+
/** Summary type — built-in aggregation functions + extensible string for custom */
|
|
90
|
+
type SummaryType = "Count" | "Average" | "Min" | "Max" | "Sum" | "Range" | "Median" | "Stddev" | "Earliest" | "Latest" | "Checked" | "Unchecked" | "Empty" | "Filled" | "Unique" | string;
|
|
91
|
+
/** Property display configuration */
|
|
92
|
+
interface PropertyConfig {
|
|
93
|
+
displayName?: string;
|
|
94
|
+
}
|
|
95
|
+
/** View definition from .base file YAML — matches full Obsidian spec */
|
|
96
|
+
interface BasesView {
|
|
97
|
+
/** View type identifier */
|
|
98
|
+
type: string;
|
|
99
|
+
/** Display name for this view (shown in view selector tab) */
|
|
100
|
+
name?: string;
|
|
101
|
+
/** Maximum number of entries to display */
|
|
102
|
+
limit?: number;
|
|
103
|
+
/** Group entries by a property */
|
|
104
|
+
groupBy?: GroupBy;
|
|
105
|
+
/** View-specific filters (merged with global filters at resolve time) */
|
|
106
|
+
filters?: FilterNode;
|
|
107
|
+
/** Sort order — list of property paths in priority order */
|
|
108
|
+
order?: string[];
|
|
109
|
+
/** Multi-key sort with explicit direction per column */
|
|
110
|
+
sort?: SortEntry[];
|
|
111
|
+
/** Per-property summary aggregations */
|
|
112
|
+
summaries?: Record<string, SummaryType>;
|
|
113
|
+
/** Column widths in pixels, keyed by property path */
|
|
114
|
+
columnSize?: Record<string, number>;
|
|
115
|
+
/** Row height in pixels */
|
|
116
|
+
rowHeight?: number;
|
|
117
|
+
/** Property name containing the image URL/path */
|
|
118
|
+
image?: string;
|
|
119
|
+
/** Card width (unitless ratio or pixels depending on renderer) */
|
|
120
|
+
cardSize?: number;
|
|
121
|
+
/** Image aspect ratio (width:height, e.g. 1 for square). Obsidian spec field. */
|
|
122
|
+
imageAspectRatio?: number;
|
|
123
|
+
/** Image fit mode: "cover" (crop to fill) or "contain" (scale to fit). Default: "cover". */
|
|
124
|
+
imageFit?: "cover" | "contain";
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated Use imageAspectRatio instead. Kept for backwards compatibility.
|
|
127
|
+
*/
|
|
128
|
+
cardAspect?: number;
|
|
129
|
+
/** Property path for the date field */
|
|
130
|
+
date?: string;
|
|
131
|
+
/** Alias for date */
|
|
132
|
+
dateField?: string;
|
|
133
|
+
/** Alias for date */
|
|
134
|
+
dateProperty?: string;
|
|
135
|
+
/** Property to group board columns by (if not using groupBy) */
|
|
136
|
+
boardProperty?: string;
|
|
137
|
+
/** Escape hatch for future/unknown view-specific fields */
|
|
138
|
+
[key: string]: unknown;
|
|
139
|
+
}
|
|
140
|
+
/** Parsed .base file data — top-level YAML structure */
|
|
141
|
+
interface BasesData {
|
|
142
|
+
/** Global filters applied to all views */
|
|
143
|
+
filters?: FilterNode;
|
|
144
|
+
/** Formula definitions — keys are formula names, values are expressions */
|
|
145
|
+
formulas?: Record<string, string>;
|
|
146
|
+
/** Property display configuration */
|
|
147
|
+
properties?: Record<string, PropertyConfig>;
|
|
148
|
+
/** Global summary configuration */
|
|
149
|
+
summaries?: Record<string, string>;
|
|
150
|
+
/** View definitions — each entry defines one tab/view */
|
|
151
|
+
views?: BasesView[];
|
|
152
|
+
}
|
|
153
|
+
/** Resolved entry — a single note that matched the base query */
|
|
154
|
+
interface BasesEntry {
|
|
155
|
+
/** The note's slug (URL path) */
|
|
156
|
+
slug: string;
|
|
157
|
+
/** Display title */
|
|
158
|
+
title: string;
|
|
159
|
+
/** All frontmatter properties (raw) */
|
|
160
|
+
properties: Record<string, unknown>;
|
|
161
|
+
/** File metadata properties */
|
|
162
|
+
fileProperties: {
|
|
163
|
+
name: string;
|
|
164
|
+
basename: string;
|
|
165
|
+
path: string;
|
|
166
|
+
folder: string;
|
|
167
|
+
ext: string;
|
|
168
|
+
tags: string[];
|
|
169
|
+
links: string[];
|
|
170
|
+
embeds?: string[];
|
|
171
|
+
created?: string | Date;
|
|
172
|
+
modified?: string | Date;
|
|
173
|
+
ctime?: Date;
|
|
174
|
+
mtime?: Date;
|
|
175
|
+
size?: number;
|
|
176
|
+
};
|
|
177
|
+
/** Computed formula values */
|
|
178
|
+
formulaValues: Record<string, unknown>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export type { BasesData, BasesEntry, BasesPageOptions, BasesView, FilterNode, GroupBy, PropertyConfig, SortDirection, SortEntry, SummaryType, ViewRenderer, ViewRendererProps, ViewTypeRegistration };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quartz-community/bases-page",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Obsidian Bases page type plugin for Quartz v5. Renders database-like filtered views of notes from .base files.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Quartz Community",
|
|
8
|
+
"homepage": "https://quartz.jzhao.xyz",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/quartz-community/bases-page"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"quartz",
|
|
15
|
+
"quartz-plugin",
|
|
16
|
+
"obsidian",
|
|
17
|
+
"bases",
|
|
18
|
+
"database",
|
|
19
|
+
"page-type"
|
|
20
|
+
],
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"CHANGELOG.md"
|
|
26
|
+
],
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./types": {
|
|
33
|
+
"types": "./dist/types.d.ts",
|
|
34
|
+
"import": "./dist/types.js"
|
|
35
|
+
},
|
|
36
|
+
"./components": {
|
|
37
|
+
"types": "./dist/components/index.d.ts",
|
|
38
|
+
"import": "./dist/components/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./registry": {
|
|
41
|
+
"types": "./dist/registry.d.ts",
|
|
42
|
+
"import": "./dist/registry.js"
|
|
43
|
+
},
|
|
44
|
+
"./compiler": {
|
|
45
|
+
"types": "./dist/compiler/index.d.ts",
|
|
46
|
+
"import": "./dist/compiler/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
49
|
+
},
|
|
50
|
+
"main": "./dist/index.js",
|
|
51
|
+
"types": "./dist/index.d.ts",
|
|
52
|
+
"sideEffects": false,
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup",
|
|
55
|
+
"dev": "tsup --watch",
|
|
56
|
+
"lint": "eslint . --max-warnings=0",
|
|
57
|
+
"format": "prettier . --check",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"check": "npm run typecheck && npm run lint && npm run format && npm run test",
|
|
61
|
+
"prepublishOnly": "npm run build"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@jackyzha0/quartz": "^5.0.0",
|
|
65
|
+
"preact": "^10.0.0",
|
|
66
|
+
"vfile": "^6.0.3"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"@jackyzha0/quartz": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"preact": {
|
|
73
|
+
"optional": false
|
|
74
|
+
},
|
|
75
|
+
"vfile": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"@quartz-community/types": "^0.2.1",
|
|
81
|
+
"@quartz-community/utils": "^0.1.0"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@types/hast": "^3.0.4",
|
|
85
|
+
"@types/mdast": "^4.0.4",
|
|
86
|
+
"@types/node": "^24.10.0",
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
88
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
89
|
+
"eslint": "^8.57.0",
|
|
90
|
+
"eslint-config-prettier": "^9.1.0",
|
|
91
|
+
"github-slugger": "^2.0.0",
|
|
92
|
+
"hast-util-from-html": "^2.0.3",
|
|
93
|
+
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
94
|
+
"preact": "^10.28.2",
|
|
95
|
+
"preact-render-to-string": "^6.6.6",
|
|
96
|
+
"prettier": "^3.6.2",
|
|
97
|
+
"sass": "^1.97.3",
|
|
98
|
+
"tsup": "^8.5.0",
|
|
99
|
+
"typescript": "^5.9.3",
|
|
100
|
+
"unist-util-visit": "^5.1.0",
|
|
101
|
+
"vfile": "^6.0.3",
|
|
102
|
+
"vitest": "^2.1.9",
|
|
103
|
+
"yaml": "^2.8.1"
|
|
104
|
+
},
|
|
105
|
+
"quartz": {
|
|
106
|
+
"name": "bases-page",
|
|
107
|
+
"displayName": "Bases Page",
|
|
108
|
+
"category": [
|
|
109
|
+
"transformer",
|
|
110
|
+
"pageType",
|
|
111
|
+
"component"
|
|
112
|
+
],
|
|
113
|
+
"version": "1.0.0",
|
|
114
|
+
"quartzVersion": ">=5.0.0",
|
|
115
|
+
"dependencies": [],
|
|
116
|
+
"defaultOrder": 50,
|
|
117
|
+
"defaultEnabled": true,
|
|
118
|
+
"defaultOptions": {
|
|
119
|
+
"defaultViewType": "table",
|
|
120
|
+
"linkResolution": "shortest"
|
|
121
|
+
},
|
|
122
|
+
"optionSchema": {
|
|
123
|
+
"defaultViewType": {
|
|
124
|
+
"type": "string"
|
|
125
|
+
},
|
|
126
|
+
"linkResolution": {
|
|
127
|
+
"type": "enum",
|
|
128
|
+
"values": [
|
|
129
|
+
"absolute",
|
|
130
|
+
"relative",
|
|
131
|
+
"shortest"
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"engines": {
|
|
137
|
+
"node": ">=22",
|
|
138
|
+
"npm": ">=10.9.2"
|
|
139
|
+
},
|
|
140
|
+
"publishConfig": {
|
|
141
|
+
"access": "public"
|
|
142
|
+
}
|
|
143
|
+
}
|