getfilepress 0.1.29 → 0.1.31

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
@@ -8,7 +8,17 @@ Written **FilePress**. npm **`getfilepress`**. CLI **`filepress`** (same script
8
8
 
9
9
  ## Start a site
10
10
 
11
- From a clone of this repo:
11
+ Shortest path: a folder with `filepress.config.ts` (`title`, `url`), `posts/*.md`, and `"getfilepress": "^0.1.29"` in `package.json`.
12
+
13
+ ```bash
14
+ pnpm install
15
+ pnpm build # → ./build/
16
+ pnpm preview # serve build/, no Genie
17
+ ```
18
+
19
+ `pnpm dev` is optional (Genie). FilePress does not upload `build/`.
20
+
21
+ From a clone of this repo, scaffold a fuller starter:
12
22
 
13
23
  ```bash
14
24
  pnpm install
@@ -18,7 +28,7 @@ cd ../my-blog && pnpm install && pnpm dev
18
28
 
19
29
  `filepress new "Title"` stamps `posts/YYYY-MM-DD-slug.md`. Config, frontmatter, images, and commands: [Docs](https://getfilepress.com/docs).
20
30
 
21
- Pin CI on npm (`getfilepress` current is `0.1.19`) or a git SHA / existing tag. `link:` is local only.
31
+ Pin CI on npm (`getfilepress` current is `0.1.29`) or a git SHA / existing tag. `link:` is local only.
22
32
 
23
33
  ## Import
24
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getfilepress",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "FilePress — file-based Markdown blog engine. Link this package from a content-only site (config + posts), then run `filepress build`.",
@@ -1,4 +1,4 @@
1
- import { readdirSync, readFileSync } from 'node:fs';
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
2
  import { isAbsolute, join, resolve } from 'node:path';
3
3
  import type { PostMeta, PostSource, RenderedPost } from './types';
4
4
  import { assertUniqueSlugs, ContentError, normalizeTag, parsePost } from './parse';
@@ -27,6 +27,7 @@ export interface ContentApi {
27
27
  }
28
28
 
29
29
  export interface CreateContentOptions {
30
+ /** Absolute or cwd-relative path to `posts/`. Missing dir → no posts (ok). */
30
31
  contentDir: string;
31
32
  /** Override draft listing. Default: on in Vite DEV, or when FILEPRESS_SHOW_DRAFTS is 1/true. */
32
33
  listDrafts?: boolean;
@@ -47,6 +48,8 @@ export function resolveListDrafts(override?: boolean): boolean {
47
48
  /**
48
49
  * Build a content API bound to one content directory. This is the seam a site
49
50
  * wires up in a server-only module: `createContent({ contentDir: 'posts' })`.
51
+ * Absent `posts/` is fine — returns empty lists. Product sites do not need a
52
+ * dummy folder.
50
53
  *
51
54
  * Reads the filesystem, so it must only be imported from server code
52
55
  * (`+page.server.ts`, `+server.ts`, or a `*.server.ts` lib module). The pure
@@ -65,6 +68,11 @@ export function createContent(opts: CreateContentOptions): ContentApi {
65
68
  function loadPostSources(): PostSource[] {
66
69
  if (cache && import.meta.env.PROD) return cache;
67
70
 
71
+ if (!existsSync(dir)) {
72
+ cache = [];
73
+ return cache;
74
+ }
75
+
68
76
  let filenames: string[];
69
77
  try {
70
78
  filenames = readdirSync(dir).filter((f) => f.toLowerCase().endsWith('.md'));