Skip to content

Commit 53911d0

Browse files
authored
feat(integration): added support for Obsidian Bases (#103)
* feat(integration): added support for Obsidian Bases * feat(integration): Added plugin categories
1 parent 11d23c4 commit 53911d0

File tree

22 files changed

+213
-54
lines changed

22 files changed

+213
-54
lines changed

docs/Settings/Integrations/base.base

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
views:
22
- type: table
33
name: Table
4+
filters:
5+
not:
6+
- file.name.startsWith("_")
47
- type: cards
58
name: Card View
69
filters:

main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ const DEFAULT_SETTINGS: QuartzSyncerSettings = {
106106
* Fantasy Statblocks documentation: {@link https://plugins.javalent.com/statblocks}
107107
*/
108108
useFantasyStatblocks: false,
109+
/**
110+
* Enable Bases integration.
111+
* This will allow the plugin to publish Obsidian Bases (.base files) to Quartz.
112+
*
113+
* Bases documentation: {@link https://help.obsidian.md/bases}
114+
*/
115+
useBases: false,
109116

110117
manageSyncerStyles: true,
111118

src/compiler/SyncerPageCompiler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export class SyncerPageCompiler {
139139
async generateMarkdown(file: PublishFile): Promise<TCompiledFile> {
140140
const vaultFileText = await file.cachedRead();
141141

142+
if (file.getType() === "base") {
143+
return [vaultFileText, { blobs: [] }];
144+
}
145+
142146
if (this.settings.useExcalidraw) {
143147
if (file.file.name.endsWith(".excalidraw.md")) {
144148
console.warn("Excalidraw files are not supported yet.");

src/compiler/integrations/auto-card-link.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export const AutoCardLinkIntegration: PluginIntegration = {
243243
name: "Auto Card Link",
244244
settingKey: "useAutoCardLink",
245245
priority: 100,
246+
category: "community",
246247

247248
assets: {
248249
scss: autoCardLinkScss,

src/compiler/integrations/bases.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
PluginIntegration,
3+
PatternDescriptor,
4+
PatternMatch,
5+
QuartzAssets,
6+
} from "./types";
7+
8+
function isBasesPluginEnabled(): boolean {
9+
// @ts-expect-error global app is available in Obsidian
10+
const internalPlugins = app?.internalPlugins;
11+
12+
if (!internalPlugins) {
13+
return false;
14+
}
15+
16+
const basesPlugin = internalPlugins.getPluginById("bases");
17+
18+
return basesPlugin?.enabled ?? false;
19+
}
20+
21+
export const BasesIntegration: PluginIntegration = {
22+
id: "bases",
23+
name: "Bases",
24+
settingKey: "useBases",
25+
priority: 200,
26+
category: "core",
27+
28+
assets: {} as QuartzAssets,
29+
30+
isAvailable(): boolean {
31+
return isBasesPluginEnabled();
32+
},
33+
34+
getPatterns(): PatternDescriptor[] {
35+
return [];
36+
},
37+
38+
async compile(match: PatternMatch): Promise<string> {
39+
return match.fullMatch;
40+
},
41+
};

src/compiler/integrations/datacore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ export const DatacoreIntegration: PluginIntegration = {
538538
name: "Datacore",
539539
settingKey: "useDatacore",
540540
priority: 100,
541+
category: "community",
541542

542543
assets: {
543544
scss: datacoreScss,

src/compiler/integrations/dataview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export const DataviewIntegration: PluginIntegration = {
7373
name: "Dataview",
7474
settingKey: "useDataview",
7575
priority: 100,
76+
category: "community",
7677

7778
assets: {} as QuartzAssets,
7879

src/compiler/integrations/excalidraw.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export const ExcalidrawIntegration: PluginIntegration = {
132132
name: "Excalidraw",
133133
settingKey: "useExcalidraw",
134134
priority: 50,
135+
category: "community",
135136

136137
assets: {
137138
scss: excalidrawScss,

src/compiler/integrations/fantasy-statblocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ export const FantasyStatblocksIntegration: PluginIntegration = {
459459
name: "Fantasy Statblocks",
460460
settingKey: "useFantasyStatblocks",
461461
priority: 100,
462+
category: "community",
462463

463464
assets: {
464465
scss: fantasyStatblocksScss,

src/compiler/integrations/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@ import { DatacoreIntegration } from "./datacore";
88
import { ExcalidrawIntegration } from "./excalidraw";
99
import { FantasyStatblocksIntegration } from "./fantasy-statblocks";
1010
import { AutoCardLinkIntegration } from "./auto-card-link";
11+
import { BasesIntegration } from "./bases";
1112

1213
export {
1314
DataviewIntegration,
1415
DatacoreIntegration,
1516
ExcalidrawIntegration,
1617
FantasyStatblocksIntegration,
1718
AutoCardLinkIntegration,
19+
BasesIntegration,
1820
};
1921

2022
integrationRegistry.register(AutoCardLinkIntegration);
2123
integrationRegistry.register(DataviewIntegration);
2224
integrationRegistry.register(DatacoreIntegration);
2325
integrationRegistry.register(ExcalidrawIntegration);
2426
integrationRegistry.register(FantasyStatblocksIntegration);
27+
integrationRegistry.register(BasesIntegration);

0 commit comments

Comments
 (0)