Skip to content

Commit 177ac92

Browse files
authored
feat: consolidate dendron configs (#1295)
* spike: draft implementation of consolidated configs * chore: add docstrings * chore: clean up and add more docstrings * chore: refactor common types * chore: add new scratch config * chore: add new insert note index configs * chore: change generic type for DendronConfigEntry * chore: respect optional when generating defaults * chore: add new random note config * chore: add more top level namespaces * chore: add namespace for insert note * chore: bunch more stuff * chore: add remaining workspace configs * chore: add graph configs * chore: add rest of publishing configs * chore: add global configs * chore: add dev configs * chore: add preview configs * chore: add dev configs to top level * chore: define generic type for config entry collection * chore: clean up commands namespace * chore: narrow down collection type definition * chore: clean up workspace namespace * chore: clean up global namespace * chore: clean up dev namespace * chore: clean up preview namespace * chore: clean up publishing namespace * chore: more cleanup * chore: more and more cleanup * chore: fix wording, add omitted configs * chore: add missing config entries in workspace * chore: conform to naming convention, various fixes * chore: remove enableCaching config * chore: renaming and deletions * chore: reduce generic type boilerplate
1 parent 426a7d2 commit 177ac92

27 files changed

+1363
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {
2+
DendronConfigEntry,
3+
VaultSyncModeEnum,
4+
} from "../../types/configs/base";
5+
6+
export const VAULT_SYNC_MODES: Record<
7+
VaultSyncModeEnum,
8+
DendronConfigEntry<string>
9+
> = {
10+
[VaultSyncModeEnum.skip]: {
11+
value: VaultSyncModeEnum.skip,
12+
label: "Skip",
13+
desc: "Skip entirely. You must manage the repository manually.",
14+
},
15+
[VaultSyncModeEnum.noPush]: {
16+
value: VaultSyncModeEnum.noPush,
17+
label: "No Push",
18+
desc: "Commit any changes and pull updates, but don't push. You can watch the repository and make local changes without sharing them back",
19+
},
20+
[VaultSyncModeEnum.noCommit]: {
21+
value: VaultSyncModeEnum.noCommit,
22+
label: "No Commit",
23+
desc: "Pull and push updates if the workspace is clean, but don't commit. You manually commit your local changes, but automatically share them once you committed.",
24+
},
25+
[VaultSyncModeEnum.sync]: {
26+
value: VaultSyncModeEnum.sync,
27+
label: "Sync",
28+
desc: "Commit changes, and pull and push updates. Treats workspace vaults like regular vaults.",
29+
},
30+
};
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
import {
2+
DendronConfigEntry,
3+
DendronConfigEntryCollection,
4+
} from "../../types/configs/base";
5+
import { DendronCommandConfig } from "../../types/configs/commands/commands";
6+
import {
7+
LookupConfig,
8+
NoteLookupConfig,
9+
LookupSelectionModeEnum,
10+
} from "../../types/configs/commands/lookup";
11+
import { RandomNoteConfig } from "../../types/configs/commands/randomNote";
12+
import { InsertNoteConfig } from "../../types/configs/commands/insertNote";
13+
import {
14+
InsertNoteLinkConfig,
15+
InsertNoteLinkAliasModeEnum,
16+
} from "../../types/configs/commands/insertNoteLink";
17+
import { InsertNoteIndexConfig } from "../../types/configs/commands/insertNoteIndex";
18+
19+
/**
20+
* Lookup
21+
*/
22+
23+
/**
24+
* Selection mode entries
25+
*/
26+
const SELECTION_MODES: Record<
27+
LookupSelectionModeEnum,
28+
DendronConfigEntry<string>
29+
> = {
30+
[LookupSelectionModeEnum.extract]: {
31+
value: LookupSelectionModeEnum.extract,
32+
label: "Extract Selection",
33+
desc: "Extract selection of active editor and use it as body of new note.",
34+
},
35+
[LookupSelectionModeEnum.link]: {
36+
value: LookupSelectionModeEnum.link,
37+
label: "Selection to Link",
38+
desc: "Use selection of active editor for the basename of the lookup value.",
39+
},
40+
[LookupSelectionModeEnum.none]: {
41+
value: LookupSelectionModeEnum.none,
42+
label: "None",
43+
desc: "Do not set selection mode",
44+
},
45+
};
46+
47+
/**
48+
* Note lookup entry collection
49+
*/
50+
const NOTE: DendronConfigEntryCollection<NoteLookupConfig> = {
51+
selectionMode: SELECTION_MODES,
52+
confirmVaultOnCreate: {
53+
label: "Confirm Vault on Create.",
54+
desc: "Prompt for vault selection when creating new note.",
55+
},
56+
};
57+
58+
/**
59+
* Lookup entry collection
60+
*/
61+
const LOOKUP: DendronConfigEntryCollection<LookupConfig> = {
62+
note: NOTE,
63+
};
64+
65+
/**
66+
* Random note
67+
*/
68+
69+
/**
70+
* Random note entries
71+
*/
72+
const RANDOM_NOTE: DendronConfigEntryCollection<RandomNoteConfig> = {
73+
include: {
74+
label: "Hierarchies to Include",
75+
desc: "Hierarchies to include when opening a random note",
76+
},
77+
exclude: {
78+
label: "hierarchies to Exclude",
79+
desc: "Hierarchies not to include when opening a random note",
80+
},
81+
};
82+
83+
/**
84+
* Insert note
85+
*/
86+
87+
/**
88+
* Insert note entries
89+
*/
90+
const INSERT_NOTE: DendronConfigEntryCollection<InsertNoteConfig> = {
91+
initialValue: {
92+
label: "Initial Value",
93+
desc: "Initial value that will be filled when prompted.",
94+
},
95+
};
96+
97+
/**
98+
* Insert note link
99+
*/
100+
101+
/**
102+
* Insert note link alias mode entries
103+
*/
104+
const ALIAS_MODES: Record<
105+
InsertNoteLinkAliasModeEnum,
106+
DendronConfigEntry<string>
107+
> = {
108+
[InsertNoteLinkAliasModeEnum.snippet]: {
109+
value: InsertNoteLinkAliasModeEnum.snippet,
110+
label: "Snippet Mode",
111+
desc: "Insert note link as snippet string",
112+
},
113+
[InsertNoteLinkAliasModeEnum.selection]: {
114+
value: InsertNoteLinkAliasModeEnum.selection,
115+
label: "Selection Mode",
116+
desc: "Extract selection and use as link alias",
117+
},
118+
[InsertNoteLinkAliasModeEnum.title]: {
119+
value: InsertNoteLinkAliasModeEnum.title,
120+
label: "Title Mode",
121+
desc: "Use linked note's title as link alias",
122+
},
123+
[InsertNoteLinkAliasModeEnum.prompt]: {
124+
value: InsertNoteLinkAliasModeEnum.prompt,
125+
label: "Prompt Mode",
126+
desc: "Prompt for input to be used as link alias",
127+
},
128+
[InsertNoteLinkAliasModeEnum.none]: {
129+
value: InsertNoteLinkAliasModeEnum.none,
130+
label: "No Alias Mode",
131+
desc: "Do not add link alias",
132+
},
133+
};
134+
135+
/**
136+
* Insert note link entries
137+
*/
138+
const INSERT_NOTE_LINK: DendronConfigEntryCollection<InsertNoteLinkConfig> = {
139+
aliasMode: ALIAS_MODES,
140+
enableMultiSelect: {
141+
label: "Enable Multi-select",
142+
desc: "Enable multi-select when inserting note links",
143+
},
144+
};
145+
146+
/**
147+
* Insert note index
148+
*/
149+
150+
/**
151+
* Insert note index entries
152+
*/
153+
export const INSERT_NOTE_INDEX: DendronConfigEntryCollection<InsertNoteIndexConfig> =
154+
{
155+
enableMarker: {
156+
label: `Enable Marker`,
157+
desc: `Insert note index between autogenerated markers`,
158+
},
159+
};
160+
161+
/**
162+
* Command entry collection
163+
*/
164+
export const COMMANDS: DendronConfigEntryCollection<DendronCommandConfig> = {
165+
lookup: LOOKUP,
166+
randomNote: RANDOM_NOTE,
167+
insertNote: INSERT_NOTE,
168+
insertNoteLink: INSERT_NOTE_LINK,
169+
insertNoteIndex: INSERT_NOTE_INDEX,
170+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { DendronConfigEntryCollection } from "../../types/configs/base";
2+
import { DendronConfig } from "../../types/configs/dendronConfig";
3+
import { GLOBAL } from "./global";
4+
import { COMMANDS } from "./commands";
5+
import { WORKSPACE } from "./workspace";
6+
import { PREVIEW } from "./preview";
7+
import { PUBLISHING } from "./publishing";
8+
import { DEV } from "./dev";
9+
10+
export const DENDRON_CONFIG: DendronConfigEntryCollection<DendronConfig> = {
11+
global: GLOBAL,
12+
commands: COMMANDS,
13+
workspace: WORKSPACE,
14+
preview: PREVIEW,
15+
publishing: PUBLISHING,
16+
dev: DEV,
17+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { DendronConfigEntryCollection } from "../../types/configs/base";
2+
import { DendronDevConfig } from "../../types/configs/dev/dev";
3+
4+
export const DEV: DendronConfigEntryCollection<DendronDevConfig> = {
5+
nextServerUrl: {
6+
label: "Next Server URL",
7+
desc: "Custom URL for the nextjs server.",
8+
},
9+
nextStaticRoot: {
10+
label: "Next Static Root",
11+
desc: "Root directory for the static assets of the nextjs server.",
12+
},
13+
engineServerPort: {
14+
label: "Engine Server Port",
15+
desc: "What port to use for the engine server. Defaults to creating on startup.",
16+
},
17+
enableWebUI: {
18+
label: "Enable web UI",
19+
desc: "Enable experimental web ui. Defaults to false.",
20+
},
21+
enableLinkCandidates: {
22+
label: "Enable Link Candidates",
23+
desc: "Enable displaying and indexing link candidates. Defaults to false.",
24+
},
25+
enablePreviewV2: {
26+
label: "Enable Preview V2",
27+
desc: "Use preview V2 as the default preview.",
28+
},
29+
};
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { TopLevelDendronConfig } from "../../types/configs/dendronConfig";
2+
import {
3+
DendronConfigEntry,
4+
DendronConfigEntryCollection,
5+
} from "../../types/configs/base";
6+
import { DendronGlobalConfig } from "../../types/configs/global/global";
7+
8+
export const ENABLE_MERMAID = (
9+
namespace: TopLevelDendronConfig
10+
): DendronConfigEntry => {
11+
return {
12+
label: `Enable Mermaid (${namespace})`,
13+
desc: `Enable the use of mermaid for rendering diagrams. (${namespace})`,
14+
};
15+
};
16+
17+
export const ENABLE_NUNJUCKS = (
18+
namespace: TopLevelDendronConfig
19+
): DendronConfigEntry => {
20+
return {
21+
label: `Enable Nunjucks (${namespace})`,
22+
desc: `Enable the use of nunjucks templates in the note body. (${namespace})`,
23+
};
24+
};
25+
26+
export const ENABLE_PRETTY_REFS = (
27+
namespace: TopLevelDendronConfig
28+
): DendronConfigEntry => {
29+
return {
30+
label: `Enable Pretty Refs (${namespace})`,
31+
desc: `Enable rendering note references as pretty refs. (${namespace})`,
32+
};
33+
};
34+
35+
export const ENABLE_KATEX = (
36+
namespace: TopLevelDendronConfig
37+
): DendronConfigEntry => {
38+
return {
39+
label: `Enable Katex (${namespace})`,
40+
desc: `Enable the use of katex for rendering math. (${namespace})`,
41+
};
42+
};
43+
44+
export const ENABLE_FM_TITLE = (
45+
namespace: TopLevelDendronConfig
46+
): DendronConfigEntry => {
47+
return {
48+
label: `Enable Frontmatter Title (${namespace})`,
49+
desc: `Insert frontmatter title of note to the body (${namespace})`,
50+
};
51+
};
52+
53+
export const ENABLE_HIERARCHY_DISPLAY = (
54+
namespace: TopLevelDendronConfig
55+
): DendronConfigEntry => {
56+
return {
57+
label: `Enable Hierarchy Display (${namespace})`,
58+
desc: `Enable rendering of children link block at the end of the note. (${namespace})`,
59+
};
60+
};
61+
62+
export const HIERARCHY_DISPLAY_TITLE = (
63+
namespace: TopLevelDendronConfig
64+
): DendronConfigEntry => {
65+
return {
66+
label: `Hierarhcy Display Title ${namespace}`,
67+
desc: `Title to display for the children links block. ${namespace}`,
68+
};
69+
};
70+
71+
export const ENABLE_NOTE_TITLE_FOR_LINK = (
72+
namespace: TopLevelDendronConfig
73+
): DendronConfigEntry => {
74+
return {
75+
label: `Enable Note Title for Links (${namespace})`,
76+
desc: `Enable rendering of naked links as the title of the note. (${namespace})`,
77+
};
78+
};
79+
80+
export const GLOBAL: DendronConfigEntryCollection<DendronGlobalConfig> = {
81+
enableFMTitle: ENABLE_FM_TITLE("global"), // TODO: split implementation to respect non-global config
82+
enableHierarchyDisplay: ENABLE_HIERARCHY_DISPLAY("global"), // TODO: split
83+
hierarchyDisplayTitle: HIERARCHY_DISPLAY_TITLE("global"), //TODO: split
84+
enableNoteTitleForLink: ENABLE_NOTE_TITLE_FOR_LINK("global"), // TODO: split
85+
enableMermaid: ENABLE_MERMAID("global"),
86+
enableNunjucks: ENABLE_NUNJUCKS("global"),
87+
enablePrettyRefs: ENABLE_PRETTY_REFS("global"),
88+
enableKatex: ENABLE_KATEX("global"),
89+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { DendronConfigEntryCollection } from "../../types/configs/base";
2+
import { DendronPreviewConfig } from "../../types/configs/preview/preview";
3+
import {
4+
ENABLE_HIERARCHY_DISPLAY,
5+
HIERARCHY_DISPLAY_TITLE,
6+
ENABLE_FM_TITLE,
7+
ENABLE_NOTE_TITLE_FOR_LINK,
8+
ENABLE_MERMAID,
9+
ENABLE_NUNJUCKS,
10+
ENABLE_KATEX,
11+
ENABLE_PRETTY_REFS,
12+
} from "./global";
13+
14+
export const PREVIEW: DendronConfigEntryCollection<DendronPreviewConfig> = {
15+
enableFMTitle: ENABLE_FM_TITLE("preview"), // TODO: split
16+
enableHierarchyDisplay: ENABLE_HIERARCHY_DISPLAY("preview"), // TODO: split
17+
hierarchyDisplayTitle: HIERARCHY_DISPLAY_TITLE("preview"), // TODO: split
18+
enableNoteTitleForLink: ENABLE_NOTE_TITLE_FOR_LINK("preview"), // TODO: split
19+
enableMermaid: ENABLE_MERMAID("preview"),
20+
enableNunjucks: ENABLE_NUNJUCKS("preview"),
21+
enablePrettyRefs: ENABLE_PRETTY_REFS("preview"),
22+
enableKatex: ENABLE_KATEX("preview"),
23+
};

0 commit comments

Comments
 (0)