@millstone/synapse-site 0.1.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/README.md +194 -0
- package/decap/build-config.ts +435 -0
- package/decap/build-vault-index.ts +178 -0
- package/decap/validate-browser.ts +638 -0
- package/package.json +67 -0
- package/plugins/CustomHeaderFooter.ts +387 -0
- package/quartz.config.ts +107 -0
- package/quartz.layout.ts +124 -0
- package/setup-quartz.ts +151 -0
- package/static/edit/body-grammars/index.json +1532 -0
- package/static/edit/config.yml +1393 -0
- package/static/edit/index.html +402 -0
- package/static/edit/schemas/index.json +1477 -0
- package/static/edit/validate.bundle.js +22720 -0
- package/static/edit/vault-index.json +78 -0
- package/sync-plugins.ts +126 -0
package/setup-quartz.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import { existsSync, copyFileSync, rmSync, symlinkSync, readFileSync, writeFileSync } from 'fs';
|
|
5
|
+
import { join, resolve } from 'path';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Setup script for Quartz 4 as a git submodule in Synapse Documentation Framework
|
|
10
|
+
* This script handles the initialization and configuration of Quartz for SYN-P1-T02
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const SITE_DIR = resolve(import.meta.dirname);
|
|
14
|
+
const QUARTZ_DIR = join(SITE_DIR, 'quartz');
|
|
15
|
+
const PROJECT_ROOT = resolve(SITE_DIR, '..');
|
|
16
|
+
const CONTENT_DIR = join(PROJECT_ROOT, 'content');
|
|
17
|
+
|
|
18
|
+
function run(command: string, options: { cwd?: string; silent?: boolean } = {}) {
|
|
19
|
+
const { cwd = SITE_DIR, silent = false } = options;
|
|
20
|
+
|
|
21
|
+
if (!silent) {
|
|
22
|
+
console.log(chalk.gray(` $ ${command}`));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
return execSync(command, {
|
|
27
|
+
cwd,
|
|
28
|
+
stdio: silent ? 'pipe' : 'inherit',
|
|
29
|
+
encoding: 'utf8'
|
|
30
|
+
});
|
|
31
|
+
} catch (error: any) {
|
|
32
|
+
console.error(chalk.red(`Failed to run: ${command}`));
|
|
33
|
+
console.error(error.message);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function setupQuartzSubmodule() {
|
|
39
|
+
console.log(chalk.cyan('𧬠Setting up Quartz 4 for Synapse Documentation...'));
|
|
40
|
+
|
|
41
|
+
// Check if submodule already exists
|
|
42
|
+
if (existsSync(QUARTZ_DIR)) {
|
|
43
|
+
console.log(chalk.yellow('ā ļø Quartz submodule already exists'));
|
|
44
|
+
|
|
45
|
+
// Check if it's initialized
|
|
46
|
+
if (!existsSync(join(QUARTZ_DIR, 'package.json'))) {
|
|
47
|
+
console.log(chalk.blue('š¦ Initializing existing submodule...'));
|
|
48
|
+
run('git submodule update --init --recursive', { cwd: PROJECT_ROOT });
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
// Add Quartz as a submodule
|
|
52
|
+
console.log(chalk.blue('š¦ Adding Quartz as a git submodule...'));
|
|
53
|
+
run('git submodule add -b v4 https://github.com/jackyzha0/quartz.git site/quartz', {
|
|
54
|
+
cwd: PROJECT_ROOT
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Install Quartz dependencies
|
|
59
|
+
console.log(chalk.blue('š¦ Installing Quartz dependencies...'));
|
|
60
|
+
run('npm install', { cwd: QUARTZ_DIR });
|
|
61
|
+
|
|
62
|
+
// Copy our configuration files
|
|
63
|
+
console.log(chalk.blue('āļø Applying Synapse configuration...'));
|
|
64
|
+
|
|
65
|
+
const configFiles = [
|
|
66
|
+
{ src: 'quartz.config.ts', dest: 'quartz.config.ts' },
|
|
67
|
+
{ src: 'quartz.layout.ts', dest: 'quartz.layout.ts' }
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
for (const { src, dest } of configFiles) {
|
|
71
|
+
const srcPath = join(SITE_DIR, src);
|
|
72
|
+
const destPath = join(QUARTZ_DIR, dest);
|
|
73
|
+
|
|
74
|
+
if (existsSync(srcPath)) {
|
|
75
|
+
// Backup original if it exists
|
|
76
|
+
if (existsSync(destPath) && !existsSync(`${destPath}.original`)) {
|
|
77
|
+
copyFileSync(destPath, `${destPath}.original`);
|
|
78
|
+
console.log(chalk.gray(` Backed up original ${dest}`));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
copyFileSync(srcPath, destPath);
|
|
82
|
+
console.log(chalk.green(` ā Copied ${src} to quartz/${dest}`));
|
|
83
|
+
} else {
|
|
84
|
+
console.log(chalk.yellow(` ā ļø ${src} not found, skipping`));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Copy custom plugins directory if it exists
|
|
89
|
+
const pluginsPath = join(SITE_DIR, 'plugins');
|
|
90
|
+
if (existsSync(pluginsPath)) {
|
|
91
|
+
const destPluginsPath = join(QUARTZ_DIR, 'plugins');
|
|
92
|
+
|
|
93
|
+
// Remove existing plugins directory if it exists
|
|
94
|
+
if (existsSync(destPluginsPath)) {
|
|
95
|
+
rmSync(destPluginsPath, { recursive: true, force: true });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Copy the plugins directory
|
|
99
|
+
run(`cp -r "${pluginsPath}" "${destPluginsPath}"`);
|
|
100
|
+
console.log(chalk.green(' ā Copied custom plugins directory'));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Create symlink to content directory
|
|
104
|
+
const quartzContentPath = join(QUARTZ_DIR, 'content');
|
|
105
|
+
|
|
106
|
+
if (existsSync(quartzContentPath)) {
|
|
107
|
+
if (!existsSync(join(quartzContentPath, '.gitkeep'))) {
|
|
108
|
+
// It's not the default empty content dir, back it up
|
|
109
|
+
if (!existsSync(`${quartzContentPath}.backup`)) {
|
|
110
|
+
console.log(chalk.gray(' Backing up existing content directory...'));
|
|
111
|
+
run(`mv content content.backup`, { cwd: QUARTZ_DIR });
|
|
112
|
+
} else {
|
|
113
|
+
rmSync(quartzContentPath, { recursive: true, force: true });
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
rmSync(quartzContentPath, { recursive: true, force: true });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log(chalk.blue('š Linking to Synapse content directory...'));
|
|
121
|
+
symlinkSync('../../content', quartzContentPath);
|
|
122
|
+
console.log(chalk.green(' ā Created symlink: quartz/content -> ../../content'));
|
|
123
|
+
|
|
124
|
+
// Add custom styles if they exist
|
|
125
|
+
const customStylesPath = join(SITE_DIR, 'custom.scss');
|
|
126
|
+
if (existsSync(customStylesPath)) {
|
|
127
|
+
const quartzStylesDir = join(QUARTZ_DIR, 'quartz', 'styles');
|
|
128
|
+
const destStylesPath = join(quartzStylesDir, 'custom.scss');
|
|
129
|
+
|
|
130
|
+
if (!existsSync(destStylesPath)) {
|
|
131
|
+
copyFileSync(customStylesPath, destStylesPath);
|
|
132
|
+
console.log(chalk.green(' ā Copied custom styles'));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
console.log(chalk.green('\nā
Quartz setup complete!\n'));
|
|
137
|
+
|
|
138
|
+
console.log(chalk.cyan('Available commands (run from site/quartz):'));
|
|
139
|
+
console.log(' npx quartz build - Build the static site');
|
|
140
|
+
console.log(' npx quartz build --serve - Serve with hot reload');
|
|
141
|
+
console.log(' npm run build - Alternative build command');
|
|
142
|
+
console.log(' npm run serve - Alternative serve command\n');
|
|
143
|
+
|
|
144
|
+
console.log(chalk.cyan('To start the development server:'));
|
|
145
|
+
console.log(chalk.white(' cd site/quartz && npx quartz build --serve'));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Run the setup
|
|
149
|
+
if (import.meta.filename === process.argv[1]) {
|
|
150
|
+
setupQuartzSubmodule();
|
|
151
|
+
}
|