@astro-minimax/cli 0.7.5 → 0.8.1

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 CHANGED
@@ -20,10 +20,10 @@ yarn dlx @astro-minimax/cli my-blog
20
20
  ```
21
21
  my-blog/
22
22
  ├── astro.config.ts # Astro + minimax integration config
23
- ├── package.json # Dependencies (core, viz, tailwind, etc.)
23
+ ├── package.json # Dependencies (core, tailwind, etc.)
24
24
  ├── tsconfig.json # TypeScript configuration
25
25
  ├── public/
26
- │ └── favicon.svg
26
+ │ └── favicon.ico
27
27
  └── src/
28
28
  ├── config.ts # SITE configuration object
29
29
  ├── constants.ts # Social links and share links
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astro-minimax/cli",
3
- "version": "0.7.5",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "description": "CLI tool for astro-minimax blog — create blogs, manage content, and process data with AI.",
6
6
  "author": "Souloss",
@@ -1,7 +1,6 @@
1
1
  import { defineConfig, envField } from "astro/config";
2
2
  import tailwindcss from "@tailwindcss/vite";
3
3
  import minimax from "@astro-minimax/core";
4
- import minimaxViz from "@astro-minimax/viz";
5
4
  import sitemap from "@astrojs/sitemap";
6
5
  import mdx from "@astrojs/mdx";
7
6
  import preact from "@astrojs/preact";
@@ -31,6 +30,7 @@ import { SITE } from "./src/config";
31
30
  import { SOCIALS, SHARE_LINKS } from "./src/constants";
32
31
  import { FRIENDS } from "./src/data/friends";
33
32
 
33
+ // Shiki transformers require type casting since they use a different type system
34
34
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
35
  const asTransformer = (t: any) => t;
36
36
 
@@ -59,9 +59,11 @@ export default defineConfig({
59
59
  shareLinks: SHARE_LINKS,
60
60
  friends: FRIENDS,
61
61
  blogPath: "src/data/blog",
62
+ viz: { mermaid: true, markmap: true },
63
+ }),
64
+ preact({
65
+ compat: true,
62
66
  }),
63
- minimaxViz({ mermaid: true, markmap: true }),
64
- preact({ compat: true }),
65
67
  sitemap({
66
68
  filter: page => SITE.showArchives || !page.endsWith("/archives"),
67
69
  }),
@@ -97,10 +99,13 @@ export default defineConfig({
97
99
  },
98
100
  },
99
101
  vite: {
100
- plugins: [tailwindcss() as never],
102
+ plugins: [
103
+ tailwindcss() as never,
104
+ ],
101
105
  server: {
102
106
  fs: {
103
- strict: false,
107
+ strict: true,
108
+ allow: ["./src", "./.astro"],
104
109
  },
105
110
  proxy: {
106
111
  "/api": {
@@ -108,18 +113,35 @@ export default defineConfig({
108
113
  changeOrigin: true,
109
114
  },
110
115
  },
116
+ warmup: {
117
+ clientFiles: [
118
+ "./src/components/**/*.astro",
119
+ "./src/layouts/**/*.astro",
120
+ ],
121
+ },
111
122
  },
112
123
  resolve: {
113
124
  alias: {
114
- "@/": new URL("./src/", import.meta.url).pathname,
125
+ "@/" : new URL("./src/", import.meta.url).pathname,
115
126
  "react": "preact/compat",
116
127
  "react-dom": "preact/compat",
117
128
  "react/jsx-runtime": "preact/jsx-runtime",
118
129
  },
119
130
  dedupe: ["preact", "preact/hooks", "preact/compat", "preact/debug", "preact/devtools", "react", "react-dom"],
120
131
  },
132
+ // Pre-bundle dependencies to speed up development and ensure consistency.
133
+ //
134
+ // WHY: By explicitly including these packages in optimizeDeps, Vite pre-bundles
135
+ // them on startup. This prevents lazy-loading race conditions where modules
136
+ // might load from different copies during dev. Particularly important for
137
+ // @ai-sdk/react which uses hooks that must resolve consistently.
138
+ //
139
+ // NOTE: Local workspace packages (@astro-minimax/*) are excluded from optimization
140
+ // because they're linked via workspace protocol and should be loaded fresh on changes.
141
+ // Excluding them also ensures JSX transformation uses Preact's jsx-runtime correctly.
121
142
  optimizeDeps: {
122
- exclude: ["@resvg/resvg-js"],
143
+ noDiscovery: true,
144
+ exclude: ["@resvg/resvg-js", "@astro-minimax/ai", "@astro-minimax/core"],
123
145
  include: [
124
146
  "preact",
125
147
  "preact/hooks",
@@ -130,9 +152,9 @@ export default defineConfig({
130
152
  "preact/jsx-dev-runtime",
131
153
  "@ai-sdk/react",
132
154
  "ai",
133
- "@astro-minimax/ai",
134
- "@astro-minimax/core",
135
- "@astro-minimax/viz",
155
+ "mermaid",
156
+ "markmap-lib",
157
+ "katex",
136
158
  ],
137
159
  },
138
160
  ssr: {
@@ -140,7 +162,6 @@ export default defineConfig({
140
162
  noExternal: [
141
163
  "@astro-minimax/ai",
142
164
  "@astro-minimax/core",
143
- "@astro-minimax/viz",
144
165
  "@ai-sdk/react",
145
166
  "ai",
146
167
  ],
@@ -7,8 +7,23 @@ import voiceProfile from '../../datas/voice-profile.json';
7
7
  import factRegistry from '../../datas/fact-registry.json';
8
8
 
9
9
  // Optional: TF-IDF vector index for enhanced search reranking
10
+ // The vector index is created by `astro-minimax ai process` command
11
+ // Lazy-loaded on first request to avoid top-level await issues with Cloudflare Pages
10
12
  let vectorIndex: unknown = null;
11
- try { vectorIndex = (await import('../../src/data/vectors/index.json')).default; } catch { /* not available */ }
13
+ let vectorIndexLoaded = false;
14
+
15
+ async function loadVectorIndex(): Promise<unknown> {
16
+ if (vectorIndexLoaded) return vectorIndex;
17
+ vectorIndexLoaded = true;
18
+ try {
19
+ // Dynamic import for optional file that may not exist
20
+ const module = await import('../../src/data/vectors/index.json');
21
+ vectorIndex = module.default;
22
+ } catch {
23
+ // File not available, keep vectorIndex as null
24
+ }
25
+ return vectorIndex;
26
+ }
12
27
 
13
28
  interface FunctionEnv extends ChatHandlerEnv {
14
29
  CACHE_KV?: KVNamespace;
@@ -17,6 +32,8 @@ interface FunctionEnv extends ChatHandlerEnv {
17
32
  }
18
33
 
19
34
  export const onRequest: PagesFunction<FunctionEnv> = async (context) => {
35
+ await loadVectorIndex();
36
+
20
37
  initializeMetadata(
21
38
  { summaries: aiSummaries, authorContext, voiceProfile, factRegistry, vectorIndex },
22
39
  context.env,
@@ -24,5 +41,6 @@ export const onRequest: PagesFunction<FunctionEnv> = async (context) => {
24
41
  return handleChatRequest({
25
42
  env: context.env,
26
43
  request: context.request,
44
+ waitUntil: context.waitUntil,
27
45
  });
28
46
  };
@@ -6,7 +6,7 @@
6
6
  "dev": "concurrently -n \"astro,ai\" -c \"blue,green\" \"astro dev\" \"pnpm exec astro-ai-dev\"",
7
7
  "dev:astro": "astro dev",
8
8
  "dev:ai": "pnpm exec astro-ai-dev",
9
- "build": "astro check && astro build && pagefind --site dist && cp -r dist/pagefind public/",
9
+ "build": "astro check && astro build && pagefind --site dist",
10
10
  "preview": "wrangler pages dev dist",
11
11
  "preview:astro": "astro preview",
12
12
  "lint": "eslint .",
@@ -28,38 +28,37 @@
28
28
  "dependencies": {
29
29
  "@ai-sdk/openai-compatible": "^2.0.35",
30
30
  "@ai-sdk/react": "^3.0.118",
31
- "@astro-minimax/ai": "^0.7.5",
32
- "@astro-minimax/core": "^0.7.5",
33
- "@astro-minimax/notify": "^0.7.5",
34
- "@astro-minimax/viz": "^0.7.5",
31
+ "@astro-minimax/ai": "^0.8.1",
32
+ "@astro-minimax/core": "^0.8.1",
33
+ "@astro-minimax/notify": "^0.8.1",
35
34
  "@astrojs/mdx": "^5.0.0",
36
35
  "@astrojs/preact": "^5.0.0",
37
36
  "@astrojs/rss": "^4.0.17",
38
37
  "@astrojs/sitemap": "^3.7.1",
39
38
  "@fontsource/ibm-plex-mono": "^5.2.7",
40
- "@resvg/resvg-js": "^2.6.0",
39
+ "@resvg/resvg-js": "^2.6.2",
41
40
  "@shikijs/rehype": "^4.0.2",
42
- "@tailwindcss/typography": "^0.5.19",
43
41
  "@tailwindcss/vite": "^4.2.1",
44
42
  "ai": "^6.0.116",
45
43
  "astro": "^6.0.0",
46
44
  "dayjs": "^1.11.19",
47
45
  "lodash.kebabcase": "^4.1.1",
46
+ "markmap-lib": "^0.18.11",
48
47
  "mermaid": "^11.12.3",
49
48
  "preact": "^10.29.0",
49
+ "qrcode": "^1.5.4",
50
50
  "rehype-katex": "^7.0.1",
51
51
  "remark-emoji": "^5.0.2",
52
52
  "remark-github-alerts": "^0.1.1",
53
- "remark-markmap": "^1.1.5",
54
53
  "remark-math": "^6.0.0",
55
- "satori": "^0.18.0",
54
+ "satori": "^0.25.0",
56
55
  "sharp": "^0.34.5",
57
56
  "slugify": "^1.6.6",
58
57
  "tailwindcss": "^4.2.1"
59
58
  },
60
59
  "devDependencies": {
61
- "@astro-minimax/cli": "^0.7.5",
62
- "@astrojs/check": "^0.9.6",
60
+ "@astro-minimax/cli": "^0.8.1",
61
+ "@astrojs/check": "^0.9.7",
63
62
  "@cloudflare/workers-types": "^4.20260313.1",
64
63
  "@pagefind/default-ui": "^1.4.0",
65
64
  "@shikijs/transformers": "^4.0.2",
Binary file
@@ -23,12 +23,12 @@ export const SITE: SiteConfig = {
23
23
  series: true,
24
24
  archives: true,
25
25
  search: true,
26
- darkMode: true,
27
26
  friends: false,
28
27
  projects: false,
29
- ai: false,
30
28
  },
31
29
 
30
+ darkMode: true,
31
+
32
32
  nav: {
33
33
  items: [
34
34
  { key: "home", enabled: true },
@@ -109,15 +109,7 @@ export const SITE: SiteConfig = {
109
109
  apiEndpoint: "/api/chat",
110
110
  },
111
111
 
112
- get lightAndDarkMode() {
113
- return this.features?.darkMode;
114
- },
115
-
116
112
  get showArchives() {
117
113
  return this.features?.archives ?? true;
118
114
  },
119
-
120
- get aiEnabled() {
121
- return (this.features?.ai ?? false) && (this.ai?.enabled ?? false);
122
- },
123
- };
115
+ };
@@ -0,0 +1,64 @@
1
+ ---
2
+ title: "GitHub Alerts Examples"
3
+ description: "Demonstrate GitHub-style alert boxes with multiple types"
4
+ pubDatetime: 2024-01-06T00:00:00.000Z
5
+ author: "Your Name"
6
+ tags:
7
+ - tutorial
8
+ category: Tutorial/Features
9
+ ---
10
+
11
+ ## What are GitHub Alerts?
12
+
13
+ GitHub Alerts are GitHub-style alert boxes that can be used to emphasize important information, warnings, or tips.
14
+
15
+ ## Basic Usage
16
+
17
+ > [!NOTE]
18
+ > This is a regular note for supplementary information.
19
+
20
+ > [!TIP]
21
+ > This is a tip that can help users use certain features better.
22
+
23
+ > [!IMPORTANT]
24
+ > This is important information that users should pay special attention to.
25
+
26
+ > [!WARNING]
27
+ > This is a warning to alert users about potential risks.
28
+
29
+ > [!CAUTION]
30
+ > This is a danger warning for irreversible operations.
31
+
32
+ ## With Formatting
33
+
34
+ > [!NOTE]
35
+ > Notes can contain **bold**, *italic*, and `code`.
36
+
37
+ > [!TIP]
38
+ > Tips can also include lists:
39
+ > - Item 1
40
+ > - Item 2
41
+ > - Item 3
42
+
43
+ > [!WARNING]
44
+ > Warnings support code blocks:
45
+ > ```bash
46
+ > rm -rf / # Never run this!
47
+ > ```
48
+
49
+ ## Use Cases
50
+
51
+ ### For Documentation
52
+
53
+ > [!TIP]
54
+ > Use alerts to highlight key points in your documentation.
55
+
56
+ ### For Tutorials
57
+
58
+ > [!IMPORTANT]
59
+ > Make sure to save your work before proceeding.
60
+
61
+ ### For API Docs
62
+
63
+ > [!WARNING]
64
+ > This endpoint is deprecated and will be removed in v2.0.
@@ -0,0 +1,99 @@
1
+ ---
2
+ title: "Code Highlighting Examples"
3
+ description: "Demonstrate Shiki code highlighting with multiple programming languages and advanced features"
4
+ pubDatetime: 2024-01-05T00:00:00.000Z
5
+ author: "Your Name"
6
+ tags:
7
+ - tutorial
8
+ - code
9
+ category: Tutorial/Features
10
+ ---
11
+
12
+ ## Basic Code Blocks
13
+
14
+ ### TypeScript
15
+
16
+ ```typescript
17
+ interface User {
18
+ id: number;
19
+ name: string;
20
+ email: string;
21
+ }
22
+
23
+ async function fetchUser(id: number): Promise<User> {
24
+ const response = await fetch(`/api/users/${id}`);
25
+ if (!response.ok) {
26
+ throw new Error('Failed to fetch user');
27
+ }
28
+ return response.json();
29
+ }
30
+
31
+ // Usage
32
+ const user = await fetchUser(1);
33
+ console.log(user.name);
34
+ ```
35
+
36
+ ### Python
37
+
38
+ ```python
39
+ from dataclasses import dataclass
40
+ from typing import Optional
41
+
42
+ @dataclass
43
+ class User:
44
+ id: int
45
+ name: str
46
+ email: Optional[str] = None
47
+
48
+ def fetch_user(user_id: int) -> User:
49
+ """Fetch a user by ID."""
50
+ # Simulate API call
51
+ return User(id=user_id, name="John Doe", email="john@example.com")
52
+
53
+ # Usage
54
+ user = fetch_user(1)
55
+ print(f"User: {user.name}")
56
+ ```
57
+
58
+ ## Advanced Features
59
+
60
+ ### Line Numbers
61
+
62
+ ```typescript showLineNumbers
63
+ function fibonacci(n: number): number {
64
+ if (n <= 1) return n;
65
+ return fibonacci(n - 1) + fibonacci(n - 2);
66
+ }
67
+
68
+ // Calculate first 10 Fibonacci numbers
69
+ for (let i = 0; i < 10; i++) {
70
+ console.log(fibonacci(i));
71
+ }
72
+ ```
73
+
74
+ ### Highlight Lines
75
+
76
+ ```typescript {2,5-7}
77
+ function processData(data: unknown) {
78
+ if (!data) throw new Error('No data provided'); // Highlighted
79
+
80
+ return {
81
+ success: true, // Highlighted
82
+ data: data, // Highlighted
83
+ timestamp: Date.now() // Highlighted
84
+ };
85
+ }
86
+ ```
87
+
88
+ ### Diff Highlighting
89
+
90
+ ```diff
91
+ function calculateTotal(items: Item[]) {
92
+ - return items.reduce((sum, item) => sum + item.price, 0);
93
+ + const subtotal = items.reduce((sum, item) => sum + item.price, 0);
94
+ + const tax = subtotal * 0.1;
95
+ + return subtotal + tax;
96
+ }
97
+ ```
98
+
99
+ For more code highlighting options, see the [Shiki documentation](https://shiki.style/).
@@ -0,0 +1,78 @@
1
+ ---
2
+ title: "Hello, World"
3
+ description: "This is my first blog post, powered by the astro-minimax theme."
4
+ pubDatetime: 2026-01-01T00:00:00.000Z
5
+ author: "Your Name"
6
+ # draft: false # Optional: Set true to hide from production
7
+ # featured: false # Optional: Set true to feature on homepage
8
+ tags:
9
+ - getting-started
10
+ category: Tutorial/Getting Started
11
+ # series: # Optional: Article series configuration
12
+ # name: "Getting Started Series"
13
+ # order: 1
14
+ ---
15
+
16
+ ## Welcome to My Blog
17
+
18
+ This is the first post created using the [astro-minimax](https://github.com/souloss/astro-minimax) theme.
19
+
20
+ ### Start Writing
21
+
22
+ Create `.md` or `.mdx` files in the `src/data/blog/en/` directory to publish new articles.
23
+
24
+ Each article requires the following frontmatter:
25
+
26
+ ```yaml
27
+ ---
28
+ title: "Article Title"
29
+ description: "Article description"
30
+ pubDatetime: 2026-01-01T00:00:00.000Z
31
+ author: "Author Name"
32
+ tags:
33
+ - tag-name
34
+ category: Category/Subcategory
35
+ ---
36
+ ```
37
+
38
+ ### Optional Fields
39
+
40
+ ```yaml
41
+ # draft: false # Set true to hide the article
42
+ # featured: false # Set true to feature on homepage
43
+ # modDatetime: ... # Last modified time
44
+ # series: # Article series configuration
45
+ # name: "Series Name"
46
+ # order: 1
47
+ ```
48
+
49
+ ### Customize the Theme
50
+
51
+ Edit `src/config.ts` to customize your blog:
52
+
53
+ ```typescript
54
+ SITE: {
55
+ title: "My Blog",
56
+ author: "Your Name",
57
+ desc: "Blog description",
58
+ // Feature toggles
59
+ features: {
60
+ tags: true, // Tags page
61
+ categories: true, // Categories page
62
+ series: true, // Series page
63
+ archives: true, // Archives page
64
+ search: true, // Search page
65
+ },
66
+ darkMode: true, // Dark mode
67
+ }
68
+ ```
69
+
70
+ ### Built-in Features
71
+
72
+ - ✅ **Markdown Extensions** - Math formulas, code highlighting, GitHub Alerts
73
+ - ✅ **Visualization** - Mermaid diagrams, Markmap mind maps
74
+ - ✅ **SEO Optimization** - Auto-generated sitemap, RSS, Open Graph
75
+ - ✅ **Multi-language** - Chinese and English support
76
+ - ✅ **Dark Mode** - Auto-follow system or manual toggle
77
+
78
+ Happy writing!
@@ -0,0 +1,100 @@
1
+ ---
2
+ title: "Markmap Mind Map Examples"
3
+ description: "Demonstrate Markmap interactive mind map functionality"
4
+ pubDatetime: 2024-01-03T00:00:00.000Z
5
+ author: "Your Name"
6
+ tags:
7
+ - tutorial
8
+ - Markmap
9
+ category: Tutorial/Tools
10
+ ---
11
+
12
+ ## What is Markmap?
13
+
14
+ Markmap is a tool that converts Markdown into interactive mind maps, perfect for presenting hierarchical content.
15
+
16
+ ## Basic Usage
17
+
18
+ ```markmap
19
+ # Central Topic
20
+
21
+ ## Branch 1
22
+ ### Sub-branch 1-1
23
+ ### Sub-branch 1-2
24
+ #### Deeper level
25
+
26
+ ## Branch 2
27
+ ### Sub-branch 2-1
28
+ ### Sub-branch 2-2
29
+
30
+ ## Branch 3
31
+ ### Sub-branch 3-1
32
+ ```
33
+
34
+ ## Learning Path Example
35
+
36
+ ```markmap
37
+ # Web Development Learning Path
38
+
39
+ ## Frontend
40
+ ### HTML & CSS
41
+ #### Semantic HTML
42
+ #### Flexbox & Grid
43
+ ### JavaScript
44
+ #### ES6+ Features
45
+ #### DOM Manipulation
46
+ ### Frameworks
47
+ #### Vue.js
48
+ #### React
49
+ #### Angular
50
+
51
+ ## Backend
52
+ ### Node.js
53
+ #### Express
54
+ #### NestJS
55
+ ### Python
56
+ #### Django
57
+ #### FastAPI
58
+ ### Databases
59
+ #### SQL
60
+ #### MongoDB
61
+
62
+ ## DevOps
63
+ ### Version Control
64
+ #### Git
65
+ ### CI/CD
66
+ #### GitHub Actions
67
+ ### Cloud
68
+ #### AWS
69
+ #### Vercel
70
+ ```
71
+
72
+ ## Project Architecture
73
+
74
+ ```markmap
75
+ # Project Structure
76
+
77
+ ## Source Code
78
+ ### Components
79
+ #### UI Components
80
+ #### Layout Components
81
+ ### Pages
82
+ #### Home
83
+ #### About
84
+ ### Services
85
+ #### API Service
86
+ #### Auth Service
87
+
88
+ ## Configuration
89
+ ### TypeScript
90
+ ### ESLint
91
+ ### Vite
92
+
93
+ ## Tests
94
+ ### Unit Tests
95
+ ### E2E Tests
96
+ ```
97
+
98
+ Click on any node to expand or collapse. This interactivity makes mind maps excellent for documentation and presentations.
99
+
100
+ For more information, visit [Markmap on GitHub](https://github.com/markmap/markmap).
@@ -0,0 +1,58 @@
1
+ ---
2
+ title: "Math Formula Examples"
3
+ description: "Demonstrate KaTeX math formula rendering with inline and block formulas"
4
+ pubDatetime: 2024-01-04T00:00:00.000Z
5
+ author: "Your Name"
6
+ tags:
7
+ - tutorial
8
+ - math
9
+ category: Tutorial/Features
10
+ ---
11
+
12
+ ## Inline Formulas
13
+
14
+ A simple inline formula: $E = mc^2$, Einstein's mass-energy equation.
15
+
16
+ Pythagorean theorem: The sum of squares of two right-angle sides equals the square of the hypotenuse, i.e., $a^2 + b^2 = c^2$.
17
+
18
+ ## Block Formulas
19
+
20
+ ### Quadratic Formula
21
+
22
+ $$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
23
+
24
+ ### Euler's Formula
25
+
26
+ $$e^{i\pi} + 1 = 0$$
27
+
28
+ ### Gaussian Integral
29
+
30
+ $$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$
31
+
32
+ ## Complex Examples
33
+
34
+ ### Matrix
35
+
36
+ $$
37
+ A = \begin{pmatrix}
38
+ a & b \\
39
+ c & d
40
+ \end{pmatrix}
41
+ $$
42
+
43
+ ### Maxwell's Equations
44
+
45
+ $$
46
+ \begin{aligned}
47
+ \nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\
48
+ \nabla \cdot \mathbf{B} &= 0 \\
49
+ \nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\
50
+ \nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t}
51
+ \end{aligned}
52
+ $$
53
+
54
+ ### Schrödinger Equation
55
+
56
+ $$i\hbar \frac{\partial}{\partial t} \Psi(\mathbf{r}, t) = \hat{H} \Psi(\mathbf{r}, t)$$
57
+
58
+ For more KaTeX syntax, see the [KaTeX Documentation](https://katex.org/).