meowpress 0.3.0-alpha.2 → 0.3.0-alpha.4
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 +71 -29
- package/dist/src/build.d.ts +21 -15
- package/dist/src/build.js +64 -42
- package/dist/src/cli.js +105 -14
- package/dist/src/content.d.ts +9 -1
- package/dist/src/content.js +86 -22
- package/dist/src/fonts.js +1 -1
- package/dist/src/identity.d.ts +6 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/output.d.ts +7 -0
- package/dist/src/output.js +111 -0
- package/dist/src/preview.d.ts +1 -0
- package/dist/src/preview.js +61 -0
- package/dist/src/site.d.ts +3 -2
- package/dist/src/site.js +154 -281
- package/dist/src/skills.d.ts +1 -0
- package/dist/src/skills.js +13 -7
- package/dist/src/theme.d.ts +12 -43
- package/dist/src/theme.js +301 -2046
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -1,30 +1,75 @@
|
|
|
1
1
|
# Meowpress
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Meowpress builds a static blog from Markdown and MDX, with a built-in Journal-based theme for posts, short notes
|
|
4
|
+
and public skills. A project can supply its own theme or page map through `meowpress/build`.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## Build and preview a site
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
Use Bun and install this version of `meowpress` with compatible `meowcss` and `meowjsx` peers.
|
|
9
|
+
When trying a workspace build, install the archives from `bun run build` and `bun run pack` in your
|
|
10
|
+
project. From that project, add your first post and build the site.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
```sh
|
|
13
|
+
mkdir -p content/posts
|
|
14
|
+
printf '# First post\n\nHello from Meowpress.\n' > content/posts/first.md
|
|
15
|
+
bunx --no-install meowpress build
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Meowpress builds `dist/index.html` and `dist/posts/first/index.html`. Put short notes in
|
|
19
|
+
`content/thoughts/` and public skills in `skills/<name>/SKILL.md`. `llms.txt` and `agents.md`
|
|
20
|
+
describe the generated site. The default theme includes `404.html` for static hosts that serve a
|
|
21
|
+
custom error page.
|
|
22
|
+
|
|
23
|
+
Run `bunx --no-install meowpress preview` to serve the built files at `http://127.0.0.1:4173`.
|
|
24
|
+
Run the build again after editing content. Deploy the `dist/` directory to a static host.
|
|
25
|
+
|
|
26
|
+
## Configure an existing repository
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
Place `meowpress.config.ts` in the project root when your content lives outside the default
|
|
29
|
+
folders or when you want to change the site name. This example uses `blog/` for posts, `notes/`
|
|
30
|
+
for short notes and `blog/assets/images/` for the homepage image.
|
|
17
31
|
|
|
18
32
|
```ts
|
|
19
33
|
import { meowSite } from "meowpress/build";
|
|
20
34
|
|
|
21
35
|
export default meowSite({
|
|
22
|
-
content:
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
content: {
|
|
37
|
+
directory: ".",
|
|
38
|
+
postsDirectory: "blog",
|
|
39
|
+
thoughtsDirectory: "notes",
|
|
40
|
+
assetsDirectory: "blog/assets",
|
|
41
|
+
},
|
|
42
|
+
site: {
|
|
43
|
+
name: "My site",
|
|
44
|
+
images: { hero: "images/cover.svg" },
|
|
45
|
+
},
|
|
25
46
|
});
|
|
26
47
|
```
|
|
27
48
|
|
|
49
|
+
The directory names in `content` are relative to its `directory`. Posts from `blog/` still have
|
|
50
|
+
URLs under `/posts/`, and notes still have URLs under `/thoughts/`. Meowpress copies `posts/assets/`
|
|
51
|
+
to `/posts/assets/`. Set `postAssetsDirectory` to change the source of those files. Posts and assets
|
|
52
|
+
whose paths contain a file or folder name starting with `_` are treated as drafts.
|
|
53
|
+
|
|
54
|
+
Pass a project path after `build` or `preview` to run from another directory. The project root
|
|
55
|
+
defaults to the current directory and is the base for relative config paths and output.
|
|
56
|
+
The CLI looks for `meowpress.config.ts`, then `site.config.ts`. Use `--config <file>` to choose a
|
|
57
|
+
file explicitly. `meowpress` and `meowpress --config ./site.config.ts` also build, and `preview`
|
|
58
|
+
accepts `--port <port>`.
|
|
59
|
+
|
|
60
|
+
Builds replace the generated output after they succeed. Meowpress reuses a nonempty default
|
|
61
|
+
`dist/` only when it contains the previous build's `agents.md` and `llms.txt`. If another tool
|
|
62
|
+
owns `dist/`, set `outputDirectory` to a separate directory and reserve it for generated files.
|
|
63
|
+
|
|
64
|
+
`includeProjectSkills: true` opts in to publishing `.agents/skills/`. Set `projectRootDirectory`
|
|
65
|
+
to choose the root for those skills. Set `notFound: false` to omit the built-in `404.html`, or
|
|
66
|
+
supply `notFound: { title, message, homeLabel }` to change its copy.
|
|
67
|
+
|
|
68
|
+
## Build from code
|
|
69
|
+
|
|
70
|
+
`meowSite()` resolves configuration and `buildSite()` writes the site. Both are exported from
|
|
71
|
+
`meowpress/build`. Use trusted local configuration and MDX, which execute code during a build.
|
|
72
|
+
|
|
28
73
|
## Pages a consumer owns
|
|
29
74
|
|
|
30
75
|
A consumer that supplies `pages` owns the whole site map. The provider receives the content that was
|
|
@@ -64,7 +109,6 @@ export default meowSite({
|
|
|
64
109
|
applies to the built-in pages as well, so a renamed stylesheet never leaves a page linking a file
|
|
65
110
|
that was not written.
|
|
66
111
|
|
|
67
|
-
Directories in the configuration are provided explicitly by the application; the default theme resolves from this package and does not depend on the startup directory.
|
|
68
112
|
The whole theme can be replaced with `theme: defineTheme(...)`; all static pages output that theme's root attributes and default options.
|
|
69
113
|
The build writes `theme.cssText` to a temporary CSS file, then lets Bun handle the other assets, and finally delivers through a stylesheet link,
|
|
70
114
|
so the theme applies without client-side JavaScript.
|
|
@@ -75,24 +119,16 @@ each package's weight-axis `woff2` files into `fonts/` with a content hash, puts
|
|
|
75
119
|
rules first in the theme stylesheet with each subset's `unicode-range`, and copies each license to
|
|
76
120
|
`licenses/<name>-OFL.txt`. A browser fetches only the files a page's text and families use, and
|
|
77
121
|
nothing for a family the page does not use, so a site with a theme switch pays only for the active
|
|
78
|
-
theme. The
|
|
122
|
+
theme. The built-in blog theme defaults to `blogFonts`, which shares Journal’s font list:
|
|
123
|
+
Newsreader (normal and italic), Inter,
|
|
124
|
+
and JetBrains Mono. Any other theme defaults to no fonts; set `fonts` explicitly to provide them,
|
|
125
|
+
or set `fonts: []` to omit font assets.
|
|
79
126
|
Install the listed packages in the site; nothing depends on an external font service.
|
|
80
|
-
|
|
127
|
+
The default pages need no images. The `hero`, `feed` and `about` keys of `site.images`
|
|
81
128
|
can explicitly set decorative image paths, for example `images/cover.svg`; paths are relative to the content root's `assets/`, the library handles each page depth,
|
|
82
129
|
and assets are delivered along the existing asset build flow. When no About image is set, the first letter of the site name is used.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
## Verification and build
|
|
87
|
-
|
|
88
|
-
After installing `meowpress` and its `meowcss` and `meowjsx` dependencies, run in the consumer directory:
|
|
89
|
-
|
|
90
|
-
```sh
|
|
91
|
-
bunx --no-install meowpress --config ./site.config.ts
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
The CLI requires Bun, and the output location is determined by `outputDirectory`. Font packages resolve from the startup directory first, then from
|
|
95
|
-
this package, which carries the default Geist, so consumers are not required to copy source, install workspace-root dependencies or access an external font service.
|
|
130
|
+
Font packages resolve from the project root first, then from this package, which carries the
|
|
131
|
+
three default font families.
|
|
96
132
|
|
|
97
133
|
## Independent verification
|
|
98
134
|
|
|
@@ -100,3 +136,9 @@ Once repository dependencies are ready, run `bun run --cwd packages/meowpress te
|
|
|
100
136
|
`bun run --cwd packages/meowpress typecheck`. Tests live in `tests/unit/`; real build tests create temporary content, themes and images through the public
|
|
101
137
|
`meowpress/build` entry,
|
|
102
138
|
covering Markdown, MDX, Thought output and draft page/asset exclusion, without reading Blog content or invoking the Blog build.
|
|
139
|
+
|
|
140
|
+
After `bun run build`, run `bun run --cwd packages/meowpress test:browser` for the Journal
|
|
141
|
+
browser regressions. The fixture server builds a temporary site through `meowpress/build` and
|
|
142
|
+
cleans it up on exit. The suite covers desktop and mobile widths in light and dark schemes,
|
|
143
|
+
repeated feed and skill-browser interactions, clipboard copy, deep 404 stylesheets, no-JavaScript
|
|
144
|
+
content, and wide-content containment. Screenshots are written to `packages/meowpress/test-results/`.
|
package/dist/src/build.d.ts
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { type ThemeDefinition } from "meowcss";
|
|
2
2
|
import { type SiteFont } from "./fonts.js";
|
|
3
|
-
import { type SiteIdentity } from "./identity.js";
|
|
3
|
+
import { type SiteIdentity, type SiteNotFound } from "./identity.js";
|
|
4
4
|
import { type ContentSourceInput, type MdxComponent } from "./content.js";
|
|
5
5
|
import { type SitePageProvider } from "./pages.js";
|
|
6
6
|
export { sitePageMarkdownFile } from "./pages.js";
|
|
7
7
|
export type { SitePage, SitePageContext, SitePageProvider } from "./pages.js";
|
|
8
|
-
export type { ContentItem } from "./content.js";
|
|
8
|
+
export type { ContentItem, ContentSource, ContentSourceInput } from "./content.js";
|
|
9
9
|
export type { SiteFont } from "./fonts.js";
|
|
10
|
-
export type { SiteIdentity } from "./identity.js";
|
|
10
|
+
export type { SiteIdentity, SiteNotFound } from "./identity.js";
|
|
11
11
|
export interface SiteConfig {
|
|
12
|
-
/**
|
|
13
|
-
content
|
|
14
|
-
/**
|
|
15
|
-
skillsDirectory
|
|
16
|
-
/** Static output directory for the generated site. */
|
|
17
|
-
outputDirectory
|
|
18
|
-
/** Defaults to
|
|
12
|
+
/** Roots containing posts, thoughts and optional assets. Defaults to `content/`. */
|
|
13
|
+
content?: ContentSourceInput | readonly ContentSourceInput[];
|
|
14
|
+
/** Root used to discover public `skills/`. Defaults to the current project directory. */
|
|
15
|
+
skillsDirectory?: string;
|
|
16
|
+
/** Static output directory for the generated site. Defaults to `dist/`. */
|
|
17
|
+
outputDirectory?: string;
|
|
18
|
+
/** Defaults to the Journal-based Blog theme. */
|
|
19
19
|
theme?: ThemeDefinition;
|
|
20
|
-
/**
|
|
20
|
+
/** Include project `.agents/skills/` in the public build. Defaults to false. */
|
|
21
|
+
includeProjectSkills?: boolean;
|
|
22
|
+
/** Alternate root for `.agents/skills/` when `includeProjectSkills` is enabled. */
|
|
21
23
|
projectRootDirectory?: string;
|
|
22
24
|
/** Site name, description, repository links and About copy; unset fields use neutral defaults. */
|
|
23
25
|
site?: Partial<SiteIdentity>;
|
|
24
|
-
/** Consumer-supplied pages
|
|
26
|
+
/** Consumer-supplied pages replace the built-in site map. */
|
|
25
27
|
pages?: SitePageProvider;
|
|
28
|
+
/** Copy for the built-in root `404.html`, or false to omit it. */
|
|
29
|
+
notFound?: SiteNotFound | false;
|
|
26
30
|
/**
|
|
27
31
|
* Markdown that opens `llms.txt` and `llms-full.txt` after the site summary: what an agent must
|
|
28
32
|
* know before following any link, such as how to install and set up what the site documents.
|
|
@@ -33,7 +37,7 @@ export interface SiteConfig {
|
|
|
33
37
|
/** Stylesheet file name for the theme; defaults to "blog-theme.css". */
|
|
34
38
|
themeStylesheet?: string;
|
|
35
39
|
/**
|
|
36
|
-
* Web fonts the theme names, published as separate files with their licenses. Defaults to
|
|
40
|
+
* Web fonts the theme names, published as separate files with their licenses. Defaults to Journal fonts
|
|
37
41
|
* for the default Blog theme and to none for any other theme.
|
|
38
42
|
*/
|
|
39
43
|
fonts?: readonly SiteFont[];
|
|
@@ -43,14 +47,16 @@ export interface ResolvedSiteConfig {
|
|
|
43
47
|
skillsDirectory: string;
|
|
44
48
|
outputDirectory: string;
|
|
45
49
|
theme: ThemeDefinition;
|
|
50
|
+
includeProjectSkills?: boolean;
|
|
46
51
|
projectRootDirectory?: string;
|
|
47
52
|
site: SiteIdentity;
|
|
48
53
|
pages?: SitePageProvider;
|
|
54
|
+
notFound?: SiteNotFound | false;
|
|
49
55
|
agentGuide?: string;
|
|
50
56
|
mdxComponents: Record<string, MdxComponent>;
|
|
51
57
|
themeStylesheet: string;
|
|
52
58
|
fonts: readonly SiteFont[];
|
|
53
59
|
}
|
|
54
60
|
/** Define a site config in the app package without taking on the build pipeline. */
|
|
55
|
-
export declare function meowSite(config
|
|
56
|
-
export declare function buildSite(input
|
|
61
|
+
export declare function meowSite(config?: SiteConfig): ResolvedSiteConfig;
|
|
62
|
+
export declare function buildSite(input?: SiteConfig | ResolvedSiteConfig): Promise<void>;
|
package/dist/src/build.js
CHANGED
|
@@ -2,28 +2,35 @@ import { removeLegacyIsFallbacks } from "meowcss/bundle";
|
|
|
2
2
|
import { blogFonts, blogTheme } from "./theme.js";
|
|
3
3
|
import { FONT_EXTERNAL, publishFonts } from "./fonts.js";
|
|
4
4
|
import { DEFAULT_SITE } from "./identity.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { constants } from "node:fs";
|
|
6
|
+
import { copyFile, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
7
8
|
import { collectContentAssets, isDraftAsset, loadSection, normalizeContentSources, } from "./content.js";
|
|
8
|
-
import { aboutPage, agentMarkdown, DEFAULT_THEME_STYLESHEET, homePage, listPage, llmFullText, llmText, postPage, skillPage, skillsIndexPage, thoughtPage, } from "./site.js";
|
|
9
|
+
import { aboutPage, agentMarkdown, DEFAULT_THEME_STYLESHEET, homePage, listPage, llmFullText, llmText, notFoundPage, postPage, skillPage, skillsIndexPage, thoughtPage, } from "./site.js";
|
|
9
10
|
import { loadSkills } from "./skills.js";
|
|
10
11
|
import { sitePageFile, sitePageMarkdownFile } from "./pages.js";
|
|
12
|
+
import { publishSite, validateBuildDestination, validateOutputDirectory } from "./output.js";
|
|
11
13
|
export { sitePageMarkdownFile } from "./pages.js";
|
|
12
14
|
/** Define a site config in the app package without taking on the build pipeline. */
|
|
13
|
-
export function meowSite(config) {
|
|
15
|
+
export function meowSite(config = {}) {
|
|
16
|
+
const themeStylesheet = config.themeStylesheet ?? DEFAULT_THEME_STYLESHEET;
|
|
17
|
+
if (basename(themeStylesheet) !== themeStylesheet || !themeStylesheet.endsWith(".css"))
|
|
18
|
+
throw new Error(`Expected a theme stylesheet file name: ${themeStylesheet}`);
|
|
14
19
|
return {
|
|
15
|
-
content: normalizeContentSources(config.content),
|
|
16
|
-
skillsDirectory: resolve(config.skillsDirectory),
|
|
17
|
-
outputDirectory: resolve(config.outputDirectory),
|
|
20
|
+
content: normalizeContentSources(config.content ?? "content"),
|
|
21
|
+
skillsDirectory: resolve(config.skillsDirectory ?? "."),
|
|
22
|
+
outputDirectory: resolve(config.outputDirectory ?? "dist"),
|
|
18
23
|
theme: config.theme ?? blogTheme,
|
|
24
|
+
includeProjectSkills: config.includeProjectSkills,
|
|
19
25
|
projectRootDirectory: config.projectRootDirectory
|
|
20
26
|
? resolve(config.projectRootDirectory)
|
|
21
27
|
: undefined,
|
|
22
28
|
site: { ...DEFAULT_SITE, ...config.site },
|
|
23
29
|
pages: config.pages,
|
|
30
|
+
notFound: config.notFound,
|
|
24
31
|
agentGuide: config.agentGuide,
|
|
25
32
|
mdxComponents: config.mdxComponents ?? {},
|
|
26
|
-
themeStylesheet
|
|
33
|
+
themeStylesheet,
|
|
27
34
|
fonts: config.fonts ?? (config.theme === undefined || config.theme === blogTheme ? blogFonts : []),
|
|
28
35
|
};
|
|
29
36
|
}
|
|
@@ -33,25 +40,23 @@ async function writePage(generatedDirectory, pathname, html) {
|
|
|
33
40
|
await writeFile(target, html, "utf8");
|
|
34
41
|
return target;
|
|
35
42
|
}
|
|
36
|
-
async function
|
|
37
|
-
const assets = await collectContentAssets(sources, { directory
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
await
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
await cp(asset.sourcePath, target, { force: true });
|
|
54
|
-
}));
|
|
43
|
+
async function writeAssets(destination, sources, directory) {
|
|
44
|
+
const assets = await collectContentAssets(sources, { directory });
|
|
45
|
+
for (const asset of assets) {
|
|
46
|
+
if (isDraftAsset(asset.sourcePath, asset.assetRoot))
|
|
47
|
+
continue;
|
|
48
|
+
const path = directory === "assets" ? asset.relativePath : join(directory, asset.relativePath);
|
|
49
|
+
const target = join(destination, path);
|
|
50
|
+
await mkdir(dirname(target), { recursive: true });
|
|
51
|
+
try {
|
|
52
|
+
await copyFile(asset.sourcePath, target, constants.COPYFILE_EXCL);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error.code !== "EEXIST")
|
|
56
|
+
throw error;
|
|
57
|
+
throw new Error(`Content asset would replace a generated file: ${path}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
55
60
|
}
|
|
56
61
|
async function buildStaticHtmlFromEntrypoints(entrypoints, generatedDirectory, outputDirectory) {
|
|
57
62
|
const result = await Bun.build({
|
|
@@ -60,13 +65,12 @@ async function buildStaticHtmlFromEntrypoints(entrypoints, generatedDirectory, o
|
|
|
60
65
|
outdir: outputDirectory,
|
|
61
66
|
target: "browser",
|
|
62
67
|
minify: true,
|
|
68
|
+
throw: false,
|
|
63
69
|
// Published font files stay separate, so subsets load by unicode-range instead of inline.
|
|
64
70
|
external: [FONT_EXTERNAL],
|
|
65
71
|
});
|
|
66
|
-
if (!result.success)
|
|
67
|
-
|
|
68
|
-
throw new Error("Unable to build site static HTML");
|
|
69
|
-
}
|
|
72
|
+
if (!result.success)
|
|
73
|
+
throw new Error(["Unable to build site static HTML", ...result.logs.map((log) => log.message)].join("\n"));
|
|
70
74
|
// Bun writes legacy :-webkit-any()/:-moz-any() copies of every :is() rule; Safari misreads them.
|
|
71
75
|
for (const output of result.outputs)
|
|
72
76
|
if (output.path.endsWith(".css"))
|
|
@@ -111,21 +115,36 @@ async function writeContentPages(generatedDirectory, posts, thoughts, theme, sit
|
|
|
111
115
|
}
|
|
112
116
|
return entrypoints;
|
|
113
117
|
}
|
|
114
|
-
export async function buildSite(input) {
|
|
118
|
+
export async function buildSite(input = {}) {
|
|
115
119
|
const config = meowSite(input);
|
|
116
|
-
|
|
120
|
+
await validateOutputDirectory(config);
|
|
121
|
+
await validateBuildDestination(config.outputDirectory);
|
|
122
|
+
const outputParent = dirname(config.outputDirectory);
|
|
123
|
+
await mkdir(outputParent, { recursive: true });
|
|
124
|
+
const workspace = await mkdtemp(join(outputParent, ".meowpress-build-"));
|
|
125
|
+
try {
|
|
126
|
+
const outputDirectory = join(workspace, "output");
|
|
127
|
+
const result = await writeSite({ ...config, outputDirectory }, join(workspace, "source"));
|
|
128
|
+
await validateBuildDestination(config.outputDirectory);
|
|
129
|
+
await publishSite(outputDirectory, config.outputDirectory);
|
|
130
|
+
console.log(`Built ${result} into ${config.outputDirectory}.`);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
await rm(workspace, { recursive: true, force: true });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function writeSite(config, generatedDirectory) {
|
|
117
137
|
const [posts, thoughts, skills] = await Promise.all([
|
|
118
138
|
loadSection(config.content, "post", { components: config.mdxComponents }),
|
|
119
139
|
loadSection(config.content, "thought", { components: config.mdxComponents }),
|
|
120
140
|
config.pages
|
|
121
141
|
? Promise.resolve([])
|
|
122
142
|
: loadSkills(config.skillsDirectory, {
|
|
143
|
+
includeProjectSkills: config.includeProjectSkills,
|
|
123
144
|
projectRootDirectory: config.projectRootDirectory,
|
|
124
145
|
}),
|
|
125
146
|
]);
|
|
126
147
|
const timeline = [...posts, ...thoughts].sort((left, right) => (right.date?.getTime() ?? 0) - (left.date?.getTime() ?? 0));
|
|
127
|
-
await rm(config.outputDirectory, { recursive: true, force: true });
|
|
128
|
-
await rm(generatedDirectory, { recursive: true, force: true });
|
|
129
148
|
await mkdir(config.outputDirectory, { recursive: true });
|
|
130
149
|
await mkdir(generatedDirectory, { recursive: true });
|
|
131
150
|
// A consumer that supplies its own pages owns the whole site map; the package's
|
|
@@ -150,6 +169,9 @@ export async function buildSite(input) {
|
|
|
150
169
|
writePage(generatedDirectory, "thoughts/index.html", listPage("thought", thoughts, config.theme, config.site, config.themeStylesheet)),
|
|
151
170
|
writePage(generatedDirectory, "skills/index.html", skillsIndexPage(skills, config.theme, config.site, config.themeStylesheet)),
|
|
152
171
|
])), ...(await writeContentPages(generatedDirectory, posts, thoughts, config.theme, config.site, config.themeStylesheet)));
|
|
172
|
+
if (config.notFound !== false) {
|
|
173
|
+
entrypoints.push(await writePage(generatedDirectory, "404.html", notFoundPage(config.notFound ?? {}, config.theme, config.site, config.themeStylesheet)));
|
|
174
|
+
}
|
|
153
175
|
for (const skill of skills) {
|
|
154
176
|
const skillPath = skill.scope === "public" ? `skills/${skill.slug}` : `skills/project/${skill.slug}`;
|
|
155
177
|
entrypoints.push(await writePage(generatedDirectory, `${skillPath}/index.html`, skillPage(skill, config.theme, config.site, config.themeStylesheet)));
|
|
@@ -159,11 +181,11 @@ export async function buildSite(input) {
|
|
|
159
181
|
// root, next to the published font directory its rules reference.
|
|
160
182
|
const fontFaces = await publishFonts(config.fonts, config.outputDirectory);
|
|
161
183
|
await writeFile(join(generatedDirectory, config.themeStylesheet), fontFaces ? `${fontFaces}\n${config.theme.cssText}` : config.theme.cssText, "utf8");
|
|
162
|
-
await
|
|
184
|
+
await writeAssets(generatedDirectory, config.content, "assets");
|
|
163
185
|
await buildStaticHtmlFromEntrypoints(entrypoints, generatedDirectory, config.outputDirectory);
|
|
164
|
-
await copyPostAssets(config.outputDirectory, config.content);
|
|
165
186
|
if (pages)
|
|
166
187
|
await writeConsumerMarkdown(config.outputDirectory, pages);
|
|
188
|
+
await writeAssets(config.outputDirectory, config.content, "posts/assets");
|
|
167
189
|
const full = pages ? llmFullText(config.site, pages, config.agentGuide) : undefined;
|
|
168
190
|
await Promise.all([
|
|
169
191
|
writeFile(join(config.outputDirectory, "llm.txt"), llmText(posts, thoughts, config.site, pages, config.agentGuide), "utf8"),
|
|
@@ -171,10 +193,10 @@ export async function buildSite(input) {
|
|
|
171
193
|
...(full === undefined
|
|
172
194
|
? []
|
|
173
195
|
: [writeFile(join(config.outputDirectory, "llms-full.txt"), full, "utf8")]),
|
|
174
|
-
writeFile(join(config.outputDirectory, "agents.md"), agentMarkdown(posts, thoughts, config.site, pages
|
|
196
|
+
writeFile(join(config.outputDirectory, "agents.md"), agentMarkdown(posts, thoughts, config.site, pages, config.content.some((source) => typeof source !== "string" &&
|
|
197
|
+
(source.postsDirectory !== undefined || source.thoughtsDirectory !== undefined))), "utf8"),
|
|
175
198
|
]);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
: `Built ${posts.length} posts and ${thoughts.length} thoughts into site dist/.`);
|
|
199
|
+
return pages
|
|
200
|
+
? `${posts.length} content items and ${pages.length} site pages`
|
|
201
|
+
: `${posts.length} posts and ${thoughts.length} thoughts`;
|
|
180
202
|
}
|
package/dist/src/cli.js
CHANGED
|
@@ -1,22 +1,113 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
+
import { stat } from "node:fs/promises";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import { pathToFileURL } from "node:url";
|
|
4
|
-
import { buildSite } from "./build.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { buildSite, meowSite } from "./build.js";
|
|
6
|
+
import { hasBuiltSite, validateOutputDirectory } from "./output.js";
|
|
7
|
+
import { serveSite } from "./preview.js";
|
|
8
|
+
const USAGE = [
|
|
9
|
+
"Usage: meowpress [--config <file>]",
|
|
10
|
+
" meowpress build [root] [--config <file>]",
|
|
11
|
+
" meowpress preview [root] [--config <file>] [--port <port>]",
|
|
12
|
+
].join("\n");
|
|
13
|
+
const CONFIG_FILES = ["meowpress.config.ts", "site.config.ts"];
|
|
14
|
+
function parseArgs(args) {
|
|
15
|
+
const command = args[0] === "preview" ? "preview" : "build";
|
|
16
|
+
const hasCommand = args[0] === command;
|
|
17
|
+
let root;
|
|
18
|
+
let config;
|
|
19
|
+
let port;
|
|
20
|
+
for (let index = hasCommand ? 1 : 0; index < args.length; index++) {
|
|
21
|
+
const arg = args[index];
|
|
22
|
+
if (arg === "--config" && config === undefined) {
|
|
23
|
+
const value = args[++index];
|
|
24
|
+
if (!value || value.startsWith("-"))
|
|
25
|
+
throw new Error("Missing file for --config");
|
|
26
|
+
config = value;
|
|
27
|
+
}
|
|
28
|
+
else if (arg === "--port" && command === "preview" && port === undefined) {
|
|
29
|
+
const value = args[++index];
|
|
30
|
+
port = Number(value);
|
|
31
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
32
|
+
throw new Error("Port must be an integer between 1 and 65535");
|
|
33
|
+
}
|
|
34
|
+
else if (hasCommand && !arg.startsWith("-") && root === undefined) {
|
|
35
|
+
root = arg;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw new Error(`Unexpected argument: ${arg}\n${USAGE}`);
|
|
39
|
+
}
|
|
10
40
|
}
|
|
11
|
-
return resolve(
|
|
41
|
+
return { command, root: resolve(root ?? "."), config, port };
|
|
42
|
+
}
|
|
43
|
+
async function loadConfig(config) {
|
|
44
|
+
for (const candidate of config === undefined ? CONFIG_FILES : [config]) {
|
|
45
|
+
const configPath = resolve(candidate);
|
|
46
|
+
try {
|
|
47
|
+
if (!(await stat(configPath)).isFile())
|
|
48
|
+
throw new Error(`Site config is not a file: ${configPath}`);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error.code !== "ENOENT")
|
|
52
|
+
throw error;
|
|
53
|
+
if (config !== undefined)
|
|
54
|
+
throw new Error(`Site config not found: ${configPath}`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const module = (await import(pathToFileURL(configPath).href));
|
|
58
|
+
const site = module.default ?? module.site;
|
|
59
|
+
if (typeof site !== "object" || site === null || Array.isArray(site))
|
|
60
|
+
throw new Error(`Expected a default site config object or a named site export in ${configPath}`);
|
|
61
|
+
return site;
|
|
62
|
+
}
|
|
63
|
+
return {};
|
|
12
64
|
}
|
|
13
65
|
export async function runSiteCli(args = Bun.argv.slice(2)) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
66
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
67
|
+
console.log(USAGE);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const options = parseArgs(args);
|
|
71
|
+
if (options.root !== process.cwd()) {
|
|
72
|
+
if (!(await stat(options.root).catch(() => undefined))?.isDirectory())
|
|
73
|
+
throw new Error(`Project root is not a directory: ${options.root}`);
|
|
74
|
+
// Trusted config can call meowSite while loading, so it and its imports need the selected cwd.
|
|
75
|
+
const child = Bun.spawn([
|
|
76
|
+
process.execPath,
|
|
77
|
+
import.meta.path,
|
|
78
|
+
options.command,
|
|
79
|
+
...(options.config ? ["--config", options.config] : []),
|
|
80
|
+
...(options.port ? ["--port", String(options.port)] : []),
|
|
81
|
+
], { cwd: options.root, stdin: "inherit", stdout: "inherit", stderr: "inherit" });
|
|
82
|
+
const interrupt = () => child.kill("SIGINT");
|
|
83
|
+
const terminate = () => child.kill("SIGTERM");
|
|
84
|
+
process.once("SIGINT", interrupt);
|
|
85
|
+
process.once("SIGTERM", terminate);
|
|
86
|
+
try {
|
|
87
|
+
process.exitCode = await child.exited;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
process.off("SIGINT", interrupt);
|
|
91
|
+
process.off("SIGTERM", terminate);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const config = await loadConfig(options.config);
|
|
96
|
+
if (options.command === "preview") {
|
|
97
|
+
const resolved = meowSite(config);
|
|
98
|
+
await validateOutputDirectory(resolved);
|
|
99
|
+
if (!(await hasBuiltSite(resolved.outputDirectory))) {
|
|
100
|
+
throw new Error(`Built site not found at ${resolved.outputDirectory}. Run meowpress build first.`);
|
|
101
|
+
}
|
|
102
|
+
const server = await serveSite(resolved.outputDirectory, options.port);
|
|
103
|
+
console.log(`Meowpress preview: ${server.url}`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
19
106
|
await buildSite(config);
|
|
20
107
|
}
|
|
21
|
-
if (import.meta.main)
|
|
22
|
-
await runSiteCli()
|
|
108
|
+
if (import.meta.main) {
|
|
109
|
+
await runSiteCli().catch((error) => {
|
|
110
|
+
console.error(error instanceof Error ? error.message : error);
|
|
111
|
+
process.exitCode = 1;
|
|
112
|
+
});
|
|
113
|
+
}
|
package/dist/src/content.d.ts
CHANGED
|
@@ -4,6 +4,14 @@ export type Frontmatter = Record<string, unknown>;
|
|
|
4
4
|
/** A content root containing `posts/`, `thoughts/`, and optional asset folders. */
|
|
5
5
|
export interface ContentSource {
|
|
6
6
|
directory: string;
|
|
7
|
+
/** Markdown and MDX posts, relative to the source root. Defaults to "posts". */
|
|
8
|
+
postsDirectory?: string;
|
|
9
|
+
/** Markdown and MDX thoughts, relative to the source root. Defaults to "thoughts". */
|
|
10
|
+
thoughtsDirectory?: string;
|
|
11
|
+
/** Assets for site pages and styles, relative to the source root. Defaults to "assets". */
|
|
12
|
+
assetsDirectory?: string;
|
|
13
|
+
/** Assets copied to /posts/assets/, relative to the source root. Defaults to "posts/assets". */
|
|
14
|
+
postAssetsDirectory?: string;
|
|
7
15
|
/** Namespace slugs and asset paths from this source to avoid collisions. */
|
|
8
16
|
slugPrefix?: string;
|
|
9
17
|
}
|
|
@@ -47,7 +55,7 @@ export interface CollectContentAssetsOptions {
|
|
|
47
55
|
directory?: string;
|
|
48
56
|
duplicate?: DuplicateContentPolicy;
|
|
49
57
|
}
|
|
50
|
-
export declare function normalizeContentSources(input: ContentSourceInput | readonly ContentSourceInput[]): ContentSource[];
|
|
58
|
+
export declare function normalizeContentSources(input: ContentSourceInput | readonly ContentSourceInput[], baseDirectory?: string): ContentSource[];
|
|
51
59
|
export declare function loadSection(sources: ContentSourceInput | readonly ContentSourceInput[], kind: ContentKind, options?: LoadSectionOptions): Promise<ContentItem[]>;
|
|
52
60
|
export declare function withoutLeadingHeading(html: string): string;
|
|
53
61
|
export declare function collectAssetFiles(directory: string): Promise<string[]>;
|