cantip 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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -0
  3. package/app/components/CanvasMount.tsx +62 -0
  4. package/app/components/CodeWrapToggle.tsx +78 -0
  5. package/app/components/FindOnPage.tsx +224 -0
  6. package/app/components/MobileBottomBar.tsx +93 -0
  7. package/app/components/MobileProjectsPanel.tsx +113 -0
  8. package/app/components/PageFloatingMenu.tsx +224 -0
  9. package/app/components/ProjectSwitcher.tsx +124 -0
  10. package/app/components/Search.tsx +930 -0
  11. package/app/components/ShortcutsHelp.tsx +113 -0
  12. package/app/components/Sidebar.tsx +1049 -0
  13. package/app/components/TabBar.tsx +227 -0
  14. package/app/components/Toc.tsx +129 -0
  15. package/app/components/TopBar.tsx +74 -0
  16. package/app/components/theme-toggle.tsx +71 -0
  17. package/app/components/ui/button.tsx +56 -0
  18. package/app/components/ui/card.tsx +55 -0
  19. package/app/components/ui/dropdown-menu.tsx +156 -0
  20. package/app/components/ui/input.tsx +21 -0
  21. package/app/entry.client.tsx +12 -0
  22. package/app/entry.server.tsx +155 -0
  23. package/app/generated/site.ts +19 -0
  24. package/app/generated/slots.ts +10 -0
  25. package/app/generated/theme.generated.css +60 -0
  26. package/app/lib/config/config.server.ts +50 -0
  27. package/app/lib/config/defaults.ts +120 -0
  28. package/app/lib/config/load.ts +82 -0
  29. package/app/lib/config/schema.ts +131 -0
  30. package/app/lib/config/site.ts +43 -0
  31. package/app/lib/content.server.ts +105 -0
  32. package/app/lib/projects.ts +86 -0
  33. package/app/lib/sidebar.server.ts +113 -0
  34. package/app/lib/site.ts +27 -0
  35. package/app/lib/slots.tsx +33 -0
  36. package/app/lib/tabs.tsx +128 -0
  37. package/app/lib/useKeyboardShortcuts.ts +149 -0
  38. package/app/lib/utils.ts +17 -0
  39. package/app/root.tsx +171 -0
  40. package/app/routes/$.tsx +158 -0
  41. package/app/routes/_index.tsx +60 -0
  42. package/app/styles/app.css +461 -0
  43. package/app/styles/obsidian.css +83 -0
  44. package/app/styles/tailwind.css +227 -0
  45. package/cli.js +119 -0
  46. package/components.json +21 -0
  47. package/dist/config.mjs +87 -0
  48. package/dist/generate-content.mjs +1665 -0
  49. package/package.json +112 -0
  50. package/scripts/build-search-index.ts +129 -0
  51. package/scripts/canonical.ts +34 -0
  52. package/scripts/canvas-to-md.ts +73 -0
  53. package/scripts/compile.ts +242 -0
  54. package/scripts/emit-config.ts +163 -0
  55. package/scripts/generate-content.ts +197 -0
  56. package/scripts/obsidian/files.ts +222 -0
  57. package/scripts/obsidian/fs.ts +34 -0
  58. package/scripts/obsidian/generate.ts +36 -0
  59. package/scripts/obsidian/html.ts +17 -0
  60. package/scripts/obsidian/logger.ts +10 -0
  61. package/scripts/obsidian/markdown.ts +56 -0
  62. package/scripts/obsidian/obsidian.ts +229 -0
  63. package/scripts/obsidian/path.ts +60 -0
  64. package/scripts/obsidian/rehype.ts +60 -0
  65. package/scripts/obsidian/remark.ts +712 -0
  66. package/scripts/obsidian/types.ts +31 -0
  67. package/vite.config.ts +62 -0
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod'
2
+ import { stripLeadingAndTrailingSlashes } from './path.ts'
3
+
4
+ export const obsidianConfigSchema = z.object({
5
+ configFolder: z.string().startsWith('.').default('.obsidian'),
6
+ copyFrontmatter: z.boolean().default(false),
7
+ ignore: z.array(z.string()).default([]),
8
+ math: z
9
+ .object({
10
+ singleDollarTextMath: z.boolean().default(true),
11
+ })
12
+ .prefault({}),
13
+ output: z
14
+ .string()
15
+ .default('notes')
16
+ .refine(
17
+ (value) => {
18
+ const label = stripLeadingAndTrailingSlashes(value)
19
+ // '.' is allowed: it means the "root" output (the general/no-project
20
+ // bucket writes straight into the content/public roots, no subdir), so
21
+ // its docs get root-level ids and are served at `/`.
22
+ return label === '.' || (label !== '' && !label.startsWith('..'))
23
+ },
24
+ { error: "The `output` directory cannot be empty or start with '..'." },
25
+ ),
26
+ skipGeneration: z.boolean().default(false),
27
+ vault: z.string(),
28
+ })
29
+
30
+ export type ObsidianConfig = z.output<typeof obsidianConfigSchema>
31
+ export type ObsidianUserConfig = z.input<typeof obsidianConfigSchema>
package/vite.config.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { fileURLToPath } from 'node:url'
2
+ import path from 'node:path'
3
+
4
+ import { vitePlugin as remix } from '@remix-run/dev'
5
+ import { defineConfig } from 'vite'
6
+ import tailwindcss from '@tailwindcss/vite'
7
+
8
+ declare module '@remix-run/node' {
9
+ interface Future {
10
+ v3_singleFetch: true
11
+ }
12
+ }
13
+
14
+ // The engine ships the Remix `app/` (routes/components/entries); the user's
15
+ // project (cwd) owns content, config, generated artifacts, public/, and build/.
16
+ //
17
+ // Vite `root` = the USER's cwd. This is what makes Remix compute a CORRECT,
18
+ // cwd-relative `assetsBuildDirectory` (`build/client`): remix-serve resolves that
19
+ // path with `express.static` from the serve cwd, so it MUST be relative to cwd,
20
+ // not the engine. (Setting root to the engine made it `../../build/client`
21
+ // relative to the engine — a path that 404s every asset at serve time.)
22
+ //
23
+ // Because the engine ships explicit `app/entry.{server,client}.tsx`, Remix skips
24
+ // its server-runtime auto-detection (which would otherwise demand
25
+ // `@remix-run/node` in the user's package.json) — so no REMIX_ROOT hack needed.
26
+ const ENGINE_DIR = path.dirname(fileURLToPath(import.meta.url))
27
+ const USER_CWD = process.cwd()
28
+
29
+ export default defineConfig({
30
+ root: USER_CWD,
31
+ // Serve the user's public/ (logos, favicon, generated /pagefind, project assets).
32
+ publicDir: path.join(USER_CWD, 'public'),
33
+ plugins: [
34
+ tailwindcss(),
35
+ remix({
36
+ ssr: true,
37
+ // The engine's app/ dir (absolute) — the single source of routes/components.
38
+ appDirectory: path.join(ENGINE_DIR, 'app'),
39
+ // Build under the user's cwd (relative to root=cwd) so `cantip start`
40
+ // finds it AND the baked asset path stays cwd-relative.
41
+ buildDirectory: 'build',
42
+ future: {
43
+ v3_fetcherPersist: true,
44
+ v3_relativeSplatPath: true,
45
+ v3_throwAbortReason: true,
46
+ v3_singleFetch: true,
47
+ v3_lazyRouteDiscovery: true,
48
+ },
49
+ }),
50
+ ],
51
+ resolve: {
52
+ alias: [
53
+ // `~/generated/*` → the USER's generated dir. The generator writes the
54
+ // importable modules (site.ts, slots.ts, theme.generated.css) under the
55
+ // user's cwd, so the alias must resolve there — NOT the engine's stale
56
+ // seed. Must precede the broader `~` alias (Vite matches in order).
57
+ { find: /^~\/generated\//, replacement: path.join(USER_CWD, 'app', 'generated') + '/' },
58
+ // `~/*` → engine app dir (everything else: components, lib, styles, routes).
59
+ { find: /^~\//, replacement: path.join(ENGINE_DIR, 'app') + '/' },
60
+ ],
61
+ },
62
+ })