@terrymooreii/sia 2.0.2 → 2.1.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/_config.yml +3 -0
- package/defaults/layouts/note.njk +1 -1
- package/defaults/layouts/post.njk +4 -1
- package/defaults/pages/blog.njk +1 -0
- package/defaults/pages/index.njk +2 -1
- package/defaults/pages/notes.njk +1 -1
- package/defaults/pages/tag.njk +1 -0
- package/defaults/styles/main.css +263 -5
- package/defaults/styles/minimal.css +1292 -0
- package/lib/assets.js +17 -4
- package/lib/build.js +9 -0
- package/lib/config.js +3 -1
- package/lib/content.js +21 -3
- package/lib/server.js +3 -3
- package/lib/templates.js +2 -1
- package/package.json +6 -1
- package/readme.md +111 -2
package/lib/assets.js
CHANGED
|
@@ -141,11 +141,24 @@ export function copyDefaultStyles(config, defaultsDir) {
|
|
|
141
141
|
return copied;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
// Copy
|
|
144
|
+
// Copy selected theme from the package
|
|
145
145
|
if (existsSync(defaultStylesDir)) {
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
const themeName = config.theme || 'main';
|
|
147
|
+
const themeFile = join(defaultStylesDir, `${themeName}.css`);
|
|
148
|
+
|
|
149
|
+
if (existsSync(themeFile)) {
|
|
150
|
+
// Copy the selected theme as main.css so templates don't need to change
|
|
151
|
+
ensureDir(outputStylesDir);
|
|
152
|
+
copyFileSync(themeFile, join(outputStylesDir, 'main.css'));
|
|
153
|
+
console.log(`🎨 Using "${themeName}" theme`);
|
|
154
|
+
return ['main.css'];
|
|
155
|
+
} else {
|
|
156
|
+
// Fallback to copying all styles if theme not found
|
|
157
|
+
console.log(`⚠️ Theme "${themeName}" not found, using default`);
|
|
158
|
+
const copied = copyAssets(defaultStylesDir, outputStylesDir);
|
|
159
|
+
console.log(`🎨 Copied ${copied.length} default style files`);
|
|
160
|
+
return copied;
|
|
161
|
+
}
|
|
149
162
|
}
|
|
150
163
|
|
|
151
164
|
console.log('⚠️ No styles found');
|
package/lib/build.js
CHANGED
|
@@ -201,6 +201,15 @@ export async function build(options = {}) {
|
|
|
201
201
|
// Load configuration
|
|
202
202
|
const config = loadConfig(options.rootDir || process.cwd());
|
|
203
203
|
|
|
204
|
+
// Only show drafts in dev mode if explicitly enabled in config
|
|
205
|
+
// For production builds, always disable showDrafts
|
|
206
|
+
if (!options.devMode) {
|
|
207
|
+
if (config.server) {
|
|
208
|
+
config.server.showDrafts = false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// If devMode is true, use the config value (which defaults to false)
|
|
212
|
+
|
|
204
213
|
// Clean output directory if requested
|
|
205
214
|
if (options.clean !== false) {
|
|
206
215
|
cleanOutput(config);
|
package/lib/config.js
CHANGED
|
@@ -10,6 +10,7 @@ const defaultConfig = {
|
|
|
10
10
|
url: 'http://localhost:3000',
|
|
11
11
|
author: 'Anonymous'
|
|
12
12
|
},
|
|
13
|
+
theme: 'main', // Theme CSS file to use: 'main' or 'minimal'
|
|
13
14
|
input: 'src',
|
|
14
15
|
output: 'dist',
|
|
15
16
|
layouts: '_layouts',
|
|
@@ -39,7 +40,8 @@ const defaultConfig = {
|
|
|
39
40
|
size: 10
|
|
40
41
|
},
|
|
41
42
|
server: {
|
|
42
|
-
port: 3000
|
|
43
|
+
port: 3000,
|
|
44
|
+
showDrafts: false // Show draft posts when using dev server
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
|
package/lib/content.js
CHANGED
|
@@ -4,6 +4,11 @@ import matter from 'gray-matter';
|
|
|
4
4
|
import { Marked } from 'marked';
|
|
5
5
|
import { markedHighlight } from 'marked-highlight';
|
|
6
6
|
import { markedEmoji } from 'marked-emoji';
|
|
7
|
+
import { gfmHeadingId } from 'marked-gfm-heading-id';
|
|
8
|
+
import footnote from 'marked-footnote';
|
|
9
|
+
import { markedSmartypants } from 'marked-smartypants';
|
|
10
|
+
import markedAlert from 'marked-alert';
|
|
11
|
+
import markedLinkifyIt from 'marked-linkify-it';
|
|
7
12
|
import hljs from 'highlight.js';
|
|
8
13
|
|
|
9
14
|
/**
|
|
@@ -77,7 +82,7 @@ const emojis = {
|
|
|
77
82
|
};
|
|
78
83
|
|
|
79
84
|
/**
|
|
80
|
-
* Configure marked with syntax highlighting and
|
|
85
|
+
* Configure marked with syntax highlighting, emoji support, and enhanced markdown features
|
|
81
86
|
*/
|
|
82
87
|
const marked = new Marked(
|
|
83
88
|
markedHighlight({
|
|
@@ -101,7 +106,12 @@ const marked = new Marked(
|
|
|
101
106
|
markedEmoji({
|
|
102
107
|
emojis,
|
|
103
108
|
renderer: (token) => token.emoji
|
|
104
|
-
})
|
|
109
|
+
}),
|
|
110
|
+
gfmHeadingId(),
|
|
111
|
+
footnote(),
|
|
112
|
+
markedSmartypants(),
|
|
113
|
+
markedAlert(),
|
|
114
|
+
markedLinkifyIt()
|
|
105
115
|
);
|
|
106
116
|
|
|
107
117
|
// Configure marked options
|
|
@@ -273,7 +283,15 @@ export function loadCollection(config, collectionName) {
|
|
|
273
283
|
return null;
|
|
274
284
|
}
|
|
275
285
|
})
|
|
276
|
-
.filter(item =>
|
|
286
|
+
.filter(item => {
|
|
287
|
+
if (item === null) return false;
|
|
288
|
+
// Include drafts if showDrafts is enabled in server config
|
|
289
|
+
if (item.draft && config.server?.showDrafts) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
// Otherwise, exclude drafts
|
|
293
|
+
return !item.draft;
|
|
294
|
+
});
|
|
277
295
|
|
|
278
296
|
// Sort items
|
|
279
297
|
const sortBy = collectionConfig.sortBy || 'date';
|
package/lib/server.js
CHANGED
|
@@ -188,7 +188,7 @@ function setupWatcher(config, wss) {
|
|
|
188
188
|
console.log('🔄 Rebuilding...\n');
|
|
189
189
|
|
|
190
190
|
try {
|
|
191
|
-
await build({ clean: false, rootDir: config.rootDir });
|
|
191
|
+
await build({ clean: false, rootDir: config.rootDir, devMode: true });
|
|
192
192
|
notifyReload(wss);
|
|
193
193
|
} catch (err) {
|
|
194
194
|
console.error('❌ Rebuild failed:', err.message);
|
|
@@ -213,8 +213,8 @@ export async function startServer(options = {}) {
|
|
|
213
213
|
|
|
214
214
|
console.log('\n⚡ Sia - Development Server\n');
|
|
215
215
|
|
|
216
|
-
// Initial build
|
|
217
|
-
await build({ clean: true, rootDir: config.rootDir });
|
|
216
|
+
// Initial build with devMode enabled to show drafts if configured
|
|
217
|
+
await build({ clean: true, rootDir: config.rootDir, devMode: true });
|
|
218
218
|
|
|
219
219
|
// Create servers
|
|
220
220
|
const httpServer = createHttpServer(config, wsPort);
|
package/lib/templates.js
CHANGED
|
@@ -24,7 +24,8 @@ function dateFilter(date, format = 'long') {
|
|
|
24
24
|
year: { year: 'numeric' },
|
|
25
25
|
month: { month: 'long', year: 'numeric' },
|
|
26
26
|
time: { hour: 'numeric', minute: '2-digit' },
|
|
27
|
-
full: { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' }
|
|
27
|
+
full: { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' },
|
|
28
|
+
full_time: { weekday: 'short', month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: '2-digit' }
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
if (format === 'iso') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrymooreii/sia",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "A simple, powerful static site generator with markdown, front matter, and Nunjucks templates",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -37,8 +37,13 @@
|
|
|
37
37
|
"highlight.js": "^11.9.0",
|
|
38
38
|
"js-yaml": "^4.1.0",
|
|
39
39
|
"marked": "^11.1.1",
|
|
40
|
+
"marked-alert": "^2.1.2",
|
|
40
41
|
"marked-emoji": "^2.0.2",
|
|
42
|
+
"marked-footnote": "^1.4.0",
|
|
43
|
+
"marked-gfm-heading-id": "^3.1.3",
|
|
41
44
|
"marked-highlight": "^2.1.0",
|
|
45
|
+
"marked-linkify-it": "^3.1.14",
|
|
46
|
+
"marked-smartypants": "^1.1.11",
|
|
42
47
|
"nunjucks": "^3.2.4",
|
|
43
48
|
"prompts": "^2.4.2",
|
|
44
49
|
"ws": "^8.16.0"
|
package/readme.md
CHANGED
|
@@ -4,6 +4,7 @@ A simple, powerful static site generator built with JavaScript. Similar to Eleve
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
+
- **Enhanced Markdown** - Syntax highlighting, emoji support, footnotes, alert boxes, auto-linkify, and more
|
|
7
8
|
- **Markdown & Front Matter** - Write content in markdown with YAML front matter
|
|
8
9
|
- **Nunjucks Templates** - Flexible templating with includes and layouts
|
|
9
10
|
- **Multiple Content Types** - Blog posts, pages, and notes (tweet-like short posts)
|
|
@@ -11,7 +12,7 @@ A simple, powerful static site generator built with JavaScript. Similar to Eleve
|
|
|
11
12
|
- **Pagination** - Built-in pagination for listing pages
|
|
12
13
|
- **Image Support** - Automatic image copying and organization
|
|
13
14
|
- **Live Reload** - Development server with hot reloading
|
|
14
|
-
- **
|
|
15
|
+
- **Themes** - Built-in themes (main, minimal) with light/dark mode toggle
|
|
15
16
|
- **RSS Feed** - Automatic RSS feed generation
|
|
16
17
|
- **YAML/JSON Config** - Flexible configuration options
|
|
17
18
|
|
|
@@ -104,6 +105,8 @@ site:
|
|
|
104
105
|
url: "https://example.com"
|
|
105
106
|
author: "Your Name"
|
|
106
107
|
|
|
108
|
+
theme: main # 'main' or 'minimal'
|
|
109
|
+
|
|
107
110
|
input: src
|
|
108
111
|
output: dist
|
|
109
112
|
|
|
@@ -128,8 +131,18 @@ pagination:
|
|
|
128
131
|
|
|
129
132
|
server:
|
|
130
133
|
port: 3000
|
|
134
|
+
showDrafts: false # Set to true to show draft posts in dev server
|
|
131
135
|
```
|
|
132
136
|
|
|
137
|
+
### Server Configuration
|
|
138
|
+
|
|
139
|
+
| Option | Description | Default |
|
|
140
|
+
|-------|-------------|---------|
|
|
141
|
+
| `port` | Port number for development server | `3000` |
|
|
142
|
+
| `showDrafts` | Show draft posts when using `sia dev` | `false` |
|
|
143
|
+
|
|
144
|
+
When `showDrafts` is set to `true`, draft posts (posts with `draft: true` in front matter) will be included in the development server build. This is useful for previewing draft content locally. Drafts are always excluded from production builds.
|
|
145
|
+
|
|
133
146
|
## Front Matter
|
|
134
147
|
|
|
135
148
|
Each markdown file can have YAML front matter:
|
|
@@ -155,9 +168,105 @@ excerpt: "Custom excerpt text"
|
|
|
155
168
|
| `tags` | Array of tags |
|
|
156
169
|
| `layout` | Template to use |
|
|
157
170
|
| `permalink` | Custom URL |
|
|
158
|
-
| `draft` | If true, excluded from build |
|
|
171
|
+
| `draft` | If true, excluded from build (unless `server.showDrafts` is enabled) |
|
|
159
172
|
| `excerpt` | Custom excerpt |
|
|
160
173
|
|
|
174
|
+
## Markdown Features
|
|
175
|
+
|
|
176
|
+
Sia supports enhanced markdown features beyond standard markdown:
|
|
177
|
+
|
|
178
|
+
### Syntax Highlighting
|
|
179
|
+
|
|
180
|
+
Code blocks are automatically highlighted using Highlight.js:
|
|
181
|
+
|
|
182
|
+
````markdown
|
|
183
|
+
```javascript
|
|
184
|
+
function hello() {
|
|
185
|
+
console.log("Hello, world!");
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
````
|
|
189
|
+
|
|
190
|
+
### Emoji Support
|
|
191
|
+
|
|
192
|
+
Use emoji shortcodes in your markdown:
|
|
193
|
+
|
|
194
|
+
```markdown
|
|
195
|
+
:smile: :rocket: :heart: :thumbsup:
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Common emojis: `:smile:`, `:heart:`, `:thumbsup:`, `:fire:`, `:rocket:`, `:star:`, `:check:`, `:warning:`, and many more.
|
|
199
|
+
|
|
200
|
+
### Heading IDs
|
|
201
|
+
|
|
202
|
+
All headings automatically get ID attributes for anchor links:
|
|
203
|
+
|
|
204
|
+
```markdown
|
|
205
|
+
## My Heading
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Becomes: `<h2 id="my-heading">My Heading</h2>`
|
|
209
|
+
|
|
210
|
+
You can link to headings within the same document:
|
|
211
|
+
|
|
212
|
+
```markdown
|
|
213
|
+
[Link to My Heading](#my-heading)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Footnotes
|
|
217
|
+
|
|
218
|
+
Add footnotes to your content:
|
|
219
|
+
|
|
220
|
+
```markdown
|
|
221
|
+
This is a sentence with a footnote[^1].
|
|
222
|
+
|
|
223
|
+
[^1]: This is the footnote content.
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Typography Enhancements
|
|
227
|
+
|
|
228
|
+
Smart typography automatically converts:
|
|
229
|
+
|
|
230
|
+
- Straight quotes (`"` and `'`) to curly quotes (`"` `"` `'` `'`)
|
|
231
|
+
- Double hyphens (`--`) to en-dash (`–`)
|
|
232
|
+
- Triple hyphens (`---`) to em-dash (`—`)
|
|
233
|
+
- Three dots (`...`) to ellipsis (`…`)
|
|
234
|
+
|
|
235
|
+
### Alert Boxes
|
|
236
|
+
|
|
237
|
+
Create GitHub Flavored Markdown-style alert boxes:
|
|
238
|
+
|
|
239
|
+
```markdown
|
|
240
|
+
> [!NOTE]
|
|
241
|
+
> This is a note alert.
|
|
242
|
+
|
|
243
|
+
> [!TIP]
|
|
244
|
+
> This is a tip alert.
|
|
245
|
+
|
|
246
|
+
> [!WARNING]
|
|
247
|
+
> This is a warning alert.
|
|
248
|
+
|
|
249
|
+
> [!CAUTION]
|
|
250
|
+
> This is a caution alert.
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Auto-Linkify
|
|
254
|
+
|
|
255
|
+
Plain URLs are automatically converted to clickable links:
|
|
256
|
+
|
|
257
|
+
```markdown
|
|
258
|
+
Visit https://example.com for more info.
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### GitHub Flavored Markdown
|
|
262
|
+
|
|
263
|
+
Full GFM support including:
|
|
264
|
+
|
|
265
|
+
- Tables
|
|
266
|
+
- Task lists (`- [ ]` and `- [x]`)
|
|
267
|
+
- Strikethrough (`~~text~~`)
|
|
268
|
+
- And more
|
|
269
|
+
|
|
161
270
|
## Templates
|
|
162
271
|
|
|
163
272
|
Sia uses Nunjucks for templating. Templates are loaded from:
|