cosmolo 0.3.2 → 0.3.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/dist/articles.d.ts +51 -0
- package/dist/articles.js +94 -0
- package/dist/categories.d.ts +7 -0
- package/dist/categories.js +26 -0
- package/dist/cli/generate.d.ts +1 -0
- package/dist/cli/generate.js +171 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +21 -0
- package/dist/cli/init.d.ts +1 -0
- package/dist/cli/init.js +154 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +9 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/loaders.d.ts +105 -0
- package/dist/loaders.js +119 -0
- package/dist/markdown.d.ts +3 -0
- package/dist/markdown.js +69 -0
- package/dist/pages.d.ts +3 -0
- package/dist/pages.js +20 -0
- package/dist/plugin.d.ts +15 -0
- package/{src/plugin.ts → dist/plugin.js} +22 -30
- package/dist/types.d.ts +58 -0
- package/dist/types.js +2 -0
- package/package.json +12 -9
- package/templates/shared/config/categories.json +6 -0
- package/templates/shared/config/site.json +10 -0
- package/templates/shared/cosmolo.config.ts +4 -4
- package/src/articles.ts +0 -124
- package/src/categories.ts +0 -35
- package/src/cli/generate.ts +0 -190
- package/src/cli/index.ts +0 -22
- package/src/cli/init.ts +0 -175
- package/src/config.ts +0 -12
- package/src/index.ts +0 -34
- package/src/loaders.ts +0 -135
- package/src/markdown.ts +0 -74
- package/src/pages.ts +0 -23
- package/src/types.ts +0 -65
- /package/{src → dist}/virtual.d.ts +0 -0
package/src/pages.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import matter from 'gray-matter';
|
|
2
|
-
import { renderMarkdown } from './markdown.js';
|
|
3
|
-
import type { Page, ResolvedCosmoloConfig } from './types.js';
|
|
4
|
-
import { rawPageFiles } from 'cosmolo:content';
|
|
5
|
-
|
|
6
|
-
function slugFromPath(filePath: string, dir: string): string {
|
|
7
|
-
const prefix = dir.replace(/^\//, '');
|
|
8
|
-
return filePath.replace(new RegExp(`^/?${prefix}/`), '').replace(/\.md$/, '');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function getPageSlugs(config: ResolvedCosmoloConfig): string[] {
|
|
12
|
-
return Object.keys(rawPageFiles).map((p) => slugFromPath(p, config.pagesDir));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function getPage(config: ResolvedCosmoloConfig, slug: string): Promise<Page> {
|
|
16
|
-
const dir = config.pagesDir.replace(/^\//, '');
|
|
17
|
-
const filePath = `/${dir}/${slug}.md`;
|
|
18
|
-
const raw = rawPageFiles[filePath];
|
|
19
|
-
if (raw === undefined) throw new Error(`Page not found: ${slug}`);
|
|
20
|
-
const { data, content } = matter(raw);
|
|
21
|
-
const html = await renderMarkdown(content);
|
|
22
|
-
return { slug, title: String(data.title ?? slug), html };
|
|
23
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// ─── Package configuration ────────────────────────────────────────────────────
|
|
2
|
-
|
|
3
|
-
export interface CosmoloConfig {
|
|
4
|
-
/** Directory containing article files (.md, .svx). @default 'src/content/articles' */
|
|
5
|
-
articlesDir?: string;
|
|
6
|
-
/** Directory containing static page files (.md). @default 'src/content/pages' */
|
|
7
|
-
pagesDir?: string;
|
|
8
|
-
/** Path to site configuration JSON. @default 'config/site.json' */
|
|
9
|
-
siteConfigPath?: string;
|
|
10
|
-
/** Path to categories configuration JSON. @default 'config/categories.json' */
|
|
11
|
-
categoriesConfigPath?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type ResolvedCosmoloConfig = Required<CosmoloConfig>;
|
|
15
|
-
|
|
16
|
-
// ─── Content types ────────────────────────────────────────────────────────────
|
|
17
|
-
|
|
18
|
-
export interface TocEntry {
|
|
19
|
-
level: number;
|
|
20
|
-
id: string;
|
|
21
|
-
text: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ArticleFrontmatter {
|
|
25
|
-
title: string;
|
|
26
|
-
category: string;
|
|
27
|
-
excerpt: string;
|
|
28
|
-
sort: number;
|
|
29
|
-
date: string;
|
|
30
|
-
tags: string[];
|
|
31
|
-
series?: string;
|
|
32
|
-
seriesOrder?: number;
|
|
33
|
-
draft: boolean;
|
|
34
|
-
related: string[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface Article extends ArticleFrontmatter {
|
|
38
|
-
slug: string;
|
|
39
|
-
html: string;
|
|
40
|
-
markdown: string;
|
|
41
|
-
toc: TocEntry[];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface Page {
|
|
45
|
-
slug: string;
|
|
46
|
-
title: string;
|
|
47
|
-
html: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface CategoryEntry {
|
|
51
|
-
slug: string;
|
|
52
|
-
label: string;
|
|
53
|
-
description: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface SiteConfig {
|
|
57
|
-
url: string;
|
|
58
|
-
name: string;
|
|
59
|
-
description: string;
|
|
60
|
-
twitterHandle: string;
|
|
61
|
-
fallbackCategoryLabel: string;
|
|
62
|
-
articlesPerPage: number;
|
|
63
|
-
ogImage: { mode: 'static' | 'generated' };
|
|
64
|
-
api: { articleBody: 'html' | 'markdown' | 'plaintext' };
|
|
65
|
-
}
|
|
File without changes
|