@jay-framework/markdown 0.22.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/agent-kit/designer/markdown-usage.md +186 -0
- package/dist/contracts/markdown-content.jay-contract +13 -0
- package/dist/contracts/markdown-live.jay-contract +14 -0
- package/dist/contracts/markdown-pages.jay-contract +53 -0
- package/dist/index.client.js +95495 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +308 -0
- package/package.json +58 -0
- package/plugin.yaml +18 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Markdown Plugin
|
|
2
|
+
|
|
3
|
+
The `@jay-framework/markdown` plugin renders markdown content as HTML in jay-html pages. It provides three headless components.
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
### markdown-pages — Directory to pages
|
|
8
|
+
|
|
9
|
+
Scans a directory of `.md` files and provides page data. Each file becomes a routable page.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<script
|
|
13
|
+
type="application/jay-headless"
|
|
14
|
+
plugin="@jay-framework/markdown"
|
|
15
|
+
contract="markdown-pages"
|
|
16
|
+
key="post"
|
|
17
|
+
>
|
|
18
|
+
contentDir: ./content
|
|
19
|
+
</script>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The component provides these ViewState fields (all slow phase):
|
|
23
|
+
|
|
24
|
+
- `{post.title}` — title from frontmatter
|
|
25
|
+
- `{post.content}` — rendered HTML
|
|
26
|
+
- `{post.description}` — description from frontmatter
|
|
27
|
+
- `{post.date}` — ISO date string
|
|
28
|
+
- `{post.tags}` — array with `{name}` field (use with forEach)
|
|
29
|
+
- `{post.frontmatter}` — full frontmatter as JSON string
|
|
30
|
+
|
|
31
|
+
SEO head tags (`<title>`, `<meta description>`, `og:title`, etc.) are injected automatically from frontmatter.
|
|
32
|
+
|
|
33
|
+
### markdown-content — Static inline renderer
|
|
34
|
+
|
|
35
|
+
Renders a markdown string at build time. Use for static content embedded in a page.
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<jay:markdown-content markdown="{myMarkdownField}">
|
|
39
|
+
<div class="md">{html}</div>
|
|
40
|
+
</jay:markdown-content>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### markdown-live — Dynamic renderer
|
|
44
|
+
|
|
45
|
+
Renders markdown that can change at request time or on the client. Ships the parser to the browser.
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<jay:markdown-live markdown="{dynamicContent}">
|
|
49
|
+
<div class="md">{html}</div>
|
|
50
|
+
</jay:markdown-live>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Markdown File Format
|
|
54
|
+
|
|
55
|
+
```markdown
|
|
56
|
+
---
|
|
57
|
+
title: Getting Started
|
|
58
|
+
date: 2026-07-15
|
|
59
|
+
description: A guide to getting started
|
|
60
|
+
author: Jane Doe
|
|
61
|
+
tags: [tutorial, beginner]
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
# Getting Started
|
|
65
|
+
|
|
66
|
+
Your content here with **bold**, _italic_, and [links](https://example.com).
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Frontmatter Fields
|
|
70
|
+
|
|
71
|
+
| Field | Purpose | Auto-injected as |
|
|
72
|
+
| ------------- | --------------- | -------------------------------------- |
|
|
73
|
+
| `title` | Page title | `<title>`, `og:title` |
|
|
74
|
+
| `description` | SEO description | `<meta description>`, `og:description` |
|
|
75
|
+
| `date` | Publish date | `article:published_time` |
|
|
76
|
+
| `author` | Author name | `<meta author>` |
|
|
77
|
+
| `image` | Cover image | `og:image` |
|
|
78
|
+
| `canonical` | Canonical URL | `<link canonical>` |
|
|
79
|
+
|
|
80
|
+
Any other field (e.g., `category: guides`) becomes `<meta name="category" content="guides">`.
|
|
81
|
+
|
|
82
|
+
## Code Highlighting
|
|
83
|
+
|
|
84
|
+
Code fences are highlighted with CSS classes. Supported languages: JavaScript/TypeScript, HTML, CSS, YAML, JSON, Bash, Python.
|
|
85
|
+
|
|
86
|
+
````markdown
|
|
87
|
+
```typescript
|
|
88
|
+
const hello = 'world';
|
|
89
|
+
```
|
|
90
|
+
````
|
|
91
|
+
|
|
92
|
+
### Output structure
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<pre class="md-code">
|
|
96
|
+
<code class="language-typescript">
|
|
97
|
+
<span class="token keyword">const</span> hello = <span class="token string">'world'</span>;
|
|
98
|
+
</code>
|
|
99
|
+
</pre>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### CSS classes
|
|
103
|
+
|
|
104
|
+
| Class | Element | Purpose |
|
|
105
|
+
| ------------------ | -------- | -------------------------------------------------- |
|
|
106
|
+
| `.md-code` | `<pre>` | Code block container |
|
|
107
|
+
| `.language-{lang}` | `<code>` | Language identifier (e.g., `.language-typescript`) |
|
|
108
|
+
|
|
109
|
+
### Token classes (inside `<code>`)
|
|
110
|
+
|
|
111
|
+
| Class | Colors in default theme | Used for |
|
|
112
|
+
| -------------------- | ------------------------ | ------------------------------------------------------------- |
|
|
113
|
+
| `.token.keyword` | `#8b5cf6` (purple) | `const`, `function`, `if`, `return`, `import`, `def`, `class` |
|
|
114
|
+
| `.token.string` | `#059669` (green) | `'hello'`, `"world"`, `` `template` `` |
|
|
115
|
+
| `.token.comment` | `#94a3b8` (gray, italic) | `// comment`, `/* block */`, `# comment` |
|
|
116
|
+
| `.token.number` | `#d97706` (amber) | `42`, `3.14`, `16px` |
|
|
117
|
+
| `.token.function` | `#2563eb` (blue) | `greet(`, `console.log(` |
|
|
118
|
+
| `.token.operator` | `#64748b` (slate) | `=`, `+`, `=>`, `&&` |
|
|
119
|
+
| `.token.punctuation` | `#94a3b8` (gray) | `{}`, `()`, `;`, `,` |
|
|
120
|
+
| `.token.tag` | `#dc2626` (red) | HTML tags: `<div`, `</span` |
|
|
121
|
+
| `.token.attribute` | `#d97706` (amber) | HTML attributes: `class=`, `href=` |
|
|
122
|
+
|
|
123
|
+
## Mermaid Diagrams
|
|
124
|
+
|
|
125
|
+
Mermaid fences are rendered to SVG on the server (via `beautiful-mermaid`). On the client (markdown-live), they output as source text for optional client-side rendering.
|
|
126
|
+
|
|
127
|
+
````markdown
|
|
128
|
+
```mermaid
|
|
129
|
+
graph LR
|
|
130
|
+
A[Start] --> B[End]
|
|
131
|
+
```
|
|
132
|
+
````
|
|
133
|
+
|
|
134
|
+
### Output structure
|
|
135
|
+
|
|
136
|
+
**Server (markdown-pages, markdown-content):**
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<div class="md-mermaid">
|
|
140
|
+
<svg>...</svg>
|
|
141
|
+
</div>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Client fallback (markdown-live):**
|
|
145
|
+
|
|
146
|
+
```html
|
|
147
|
+
<div class="md-mermaid">
|
|
148
|
+
<pre class="md-mermaid-source">
|
|
149
|
+
graph LR
|
|
150
|
+
A[Start] --> B[End]</pre
|
|
151
|
+
>
|
|
152
|
+
</div>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### CSS classes
|
|
156
|
+
|
|
157
|
+
| Class | Element | Purpose |
|
|
158
|
+
| -------------------- | ------- | ------------------------------------------------- |
|
|
159
|
+
| `.md-mermaid` | `<div>` | Mermaid diagram container (centered, with margin) |
|
|
160
|
+
| `.md-mermaid svg` | `<svg>` | The rendered SVG diagram (max-width: 100%) |
|
|
161
|
+
| `.md-mermaid-source` | `<pre>` | Raw mermaid source (client fallback only) |
|
|
162
|
+
| `.md-mermaid-error` | `<pre>` | Error message when rendering fails |
|
|
163
|
+
|
|
164
|
+
## Theme CSS
|
|
165
|
+
|
|
166
|
+
Import a theme in your project CSS:
|
|
167
|
+
|
|
168
|
+
```css
|
|
169
|
+
@import '@jay-framework/markdown/themes/markdown-blog.css';
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Available themes:
|
|
173
|
+
|
|
174
|
+
- `markdown-default.css` — clean, neutral
|
|
175
|
+
- `markdown-docs.css` — documentation style (narrower, tighter)
|
|
176
|
+
- `markdown-blog.css` — blog style (wider body text, generous spacing)
|
|
177
|
+
|
|
178
|
+
Override via CSS custom properties:
|
|
179
|
+
|
|
180
|
+
```css
|
|
181
|
+
.md {
|
|
182
|
+
--md-color-link: var(--accent);
|
|
183
|
+
--md-color-heading: var(--text-primary);
|
|
184
|
+
--md-color-code-bg: var(--bg-secondary);
|
|
185
|
+
}
|
|
186
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
name: markdown-live
|
|
2
|
+
description: Renders markdown with fast+interactive updates
|
|
3
|
+
|
|
4
|
+
props:
|
|
5
|
+
- name: markdown
|
|
6
|
+
kind: required
|
|
7
|
+
phase: fast+interactive
|
|
8
|
+
description: Markdown string to render
|
|
9
|
+
|
|
10
|
+
tags:
|
|
11
|
+
- tag: html
|
|
12
|
+
type: data
|
|
13
|
+
dataType: html-string
|
|
14
|
+
phase: fast+interactive
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: markdown-pages
|
|
2
|
+
description: Renders a directory of markdown files as routable pages
|
|
3
|
+
|
|
4
|
+
props:
|
|
5
|
+
- name: contentDir
|
|
6
|
+
kind: required
|
|
7
|
+
description: Path to markdown directory (relative to page)
|
|
8
|
+
|
|
9
|
+
params:
|
|
10
|
+
- name: slug
|
|
11
|
+
kind: required
|
|
12
|
+
|
|
13
|
+
tags:
|
|
14
|
+
- tag: title
|
|
15
|
+
type: data
|
|
16
|
+
dataType: string
|
|
17
|
+
phase: slow
|
|
18
|
+
description: Title from frontmatter
|
|
19
|
+
|
|
20
|
+
- tag: content
|
|
21
|
+
type: data
|
|
22
|
+
dataType: html-string
|
|
23
|
+
phase: slow
|
|
24
|
+
description: Rendered HTML from markdown body
|
|
25
|
+
|
|
26
|
+
- tag: description
|
|
27
|
+
type: data
|
|
28
|
+
dataType: string
|
|
29
|
+
phase: slow
|
|
30
|
+
description: Description from frontmatter
|
|
31
|
+
|
|
32
|
+
- tag: date
|
|
33
|
+
type: data
|
|
34
|
+
dataType: string
|
|
35
|
+
phase: slow
|
|
36
|
+
description: Date from frontmatter (ISO string)
|
|
37
|
+
|
|
38
|
+
- tag: tags
|
|
39
|
+
type: sub-contract
|
|
40
|
+
repeated: true
|
|
41
|
+
trackBy: name
|
|
42
|
+
phase: slow
|
|
43
|
+
description: Tags from frontmatter
|
|
44
|
+
tags:
|
|
45
|
+
- tag: name
|
|
46
|
+
type: data
|
|
47
|
+
dataType: string
|
|
48
|
+
|
|
49
|
+
- tag: frontmatter
|
|
50
|
+
type: data
|
|
51
|
+
dataType: string
|
|
52
|
+
phase: slow
|
|
53
|
+
description: Full frontmatter as JSON string (for custom fields)
|