@moonwave99/goffre 0.1.3 → 0.1.5
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 +6 -9
- package/dist/index.d.ts +107 -41
- package/dist/index.js +4832 -41
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -15,16 +15,13 @@ npm install @moonwave99/goffre --save
|
|
|
15
15
|
```js
|
|
16
16
|
import { load, render } from "@moonwave99/goffre";
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
try {
|
|
19
19
|
const { pages } = await load();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
console.log("Error generating site", error);
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
20
|
+
const results = await render({ pages });
|
|
21
|
+
console.log(`Generated ${results.length} pages`);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.log("Error generating site", error);
|
|
24
|
+
}
|
|
28
25
|
```
|
|
29
26
|
|
|
30
27
|
Default paths:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,6 @@
|
|
|
1
1
|
import { MarkedExtension, RendererObject } from 'marked';
|
|
2
2
|
import { HelperOptions } from 'handlebars';
|
|
3
3
|
|
|
4
|
-
type Context = {
|
|
5
|
-
data: {
|
|
6
|
-
root: {
|
|
7
|
-
options?: {
|
|
8
|
-
domain?: string;
|
|
9
|
-
env?: {
|
|
10
|
-
mode?: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
type HelperContext = Context & Omit<HelperOptions, "fn" | "inverse">;
|
|
17
|
-
type BlockContext = Context & HelperOptions;
|
|
18
|
-
declare const markdown: (text: string) => string | Promise<string>;
|
|
19
|
-
declare const getParamLink: (url: string, options: HelperContext) => string;
|
|
20
|
-
declare const getAsset: (asset: string, context: Omit<HelperContext, "hash">) => string;
|
|
21
|
-
declare const getSitemapLink: (page: Page, context: HelperContext) => string;
|
|
22
|
-
declare const getLink: (page: Page, context: HelperContext) => string;
|
|
23
|
-
declare const getNavClass: ({ slug }: Page, currentPage: Page) => string;
|
|
24
|
-
declare const list: (context: Page[], options: BlockContext) => string;
|
|
25
|
-
declare const nextItem: (context: Page, options: Pick<BlockContext, "hash" | "fn">) => string | undefined;
|
|
26
|
-
declare const prevItem: (context: Page, options: Pick<BlockContext, "hash" | "fn">) => string | undefined;
|
|
27
|
-
|
|
28
|
-
declare const defaultHelpers_getAsset: typeof getAsset;
|
|
29
|
-
declare const defaultHelpers_getLink: typeof getLink;
|
|
30
|
-
declare const defaultHelpers_getNavClass: typeof getNavClass;
|
|
31
|
-
declare const defaultHelpers_getParamLink: typeof getParamLink;
|
|
32
|
-
declare const defaultHelpers_getSitemapLink: typeof getSitemapLink;
|
|
33
|
-
declare const defaultHelpers_list: typeof list;
|
|
34
|
-
declare const defaultHelpers_markdown: typeof markdown;
|
|
35
|
-
declare const defaultHelpers_nextItem: typeof nextItem;
|
|
36
|
-
declare const defaultHelpers_prevItem: typeof prevItem;
|
|
37
|
-
declare namespace defaultHelpers {
|
|
38
|
-
export { defaultHelpers_getAsset as getAsset, defaultHelpers_getLink as getLink, defaultHelpers_getNavClass as getNavClass, defaultHelpers_getParamLink as getParamLink, defaultHelpers_getSitemapLink as getSitemapLink, defaultHelpers_list as list, defaultHelpers_markdown as markdown, defaultHelpers_nextItem as nextItem, defaultHelpers_prevItem as prevItem };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare const helpers: typeof defaultHelpers;
|
|
42
4
|
type Page = {
|
|
43
5
|
slug: string;
|
|
44
6
|
link?: string;
|
|
@@ -60,7 +22,7 @@ type LoadParams = {
|
|
|
60
22
|
declare function load({ dataPath }?: LoadParams): Promise<{
|
|
61
23
|
json: {};
|
|
62
24
|
pages: {
|
|
63
|
-
excerpt: string
|
|
25
|
+
excerpt: string;
|
|
64
26
|
slug: string;
|
|
65
27
|
description: any;
|
|
66
28
|
content: string;
|
|
@@ -68,7 +30,7 @@ declare function load({ dataPath }?: LoadParams): Promise<{
|
|
|
68
30
|
}>;
|
|
69
31
|
declare function loadJSON(cwd: string): Promise<{}>;
|
|
70
32
|
declare function loadMarkdown(cwd: string): Promise<{
|
|
71
|
-
excerpt: string
|
|
33
|
+
excerpt: string;
|
|
72
34
|
slug: string;
|
|
73
35
|
description: any;
|
|
74
36
|
content: string;
|
|
@@ -119,4 +81,108 @@ type PaginatedResult<T extends Page> = {
|
|
|
119
81
|
};
|
|
120
82
|
declare function paginate<T extends Page>({ collection, size, sortBy, order, }: PaginateParams<T>): PaginatedResult<T>[];
|
|
121
83
|
|
|
122
|
-
|
|
84
|
+
type Context = {
|
|
85
|
+
data: {
|
|
86
|
+
root: {
|
|
87
|
+
options?: {
|
|
88
|
+
domain?: string;
|
|
89
|
+
env?: {
|
|
90
|
+
mode?: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
type HelperContext = Context & Omit<HelperOptions, "fn" | "inverse">;
|
|
97
|
+
type BlockContext = Context & HelperOptions;
|
|
98
|
+
declare const markdown: (text: string) => string | Promise<string>;
|
|
99
|
+
declare function getExcerpt(content: string): Promise<string>;
|
|
100
|
+
declare const getParamLink: (url: string, options: HelperContext) => string;
|
|
101
|
+
declare const getAsset: (asset: string, context: Omit<HelperContext, "hash">) => string;
|
|
102
|
+
declare const getSitemapLink: (page: Page, context: HelperContext) => string;
|
|
103
|
+
declare const getLink: (page: Page, context: HelperContext) => string;
|
|
104
|
+
declare const getNavClass: ({ slug }: Page, currentPage: Page) => string;
|
|
105
|
+
declare const list: (context: Page[], options: BlockContext) => string;
|
|
106
|
+
declare const nextItem: (context: Page, options: Pick<BlockContext, "hash" | "fn">) => string | undefined;
|
|
107
|
+
declare const prevItem: (context: Page, options: Pick<BlockContext, "hash" | "fn">) => string | undefined;
|
|
108
|
+
|
|
109
|
+
declare const helpers_getAsset: typeof getAsset;
|
|
110
|
+
declare const helpers_getExcerpt: typeof getExcerpt;
|
|
111
|
+
declare const helpers_getLink: typeof getLink;
|
|
112
|
+
declare const helpers_getNavClass: typeof getNavClass;
|
|
113
|
+
declare const helpers_getParamLink: typeof getParamLink;
|
|
114
|
+
declare const helpers_getSitemapLink: typeof getSitemapLink;
|
|
115
|
+
declare const helpers_list: typeof list;
|
|
116
|
+
declare const helpers_markdown: typeof markdown;
|
|
117
|
+
declare const helpers_nextItem: typeof nextItem;
|
|
118
|
+
declare const helpers_prevItem: typeof prevItem;
|
|
119
|
+
declare namespace helpers {
|
|
120
|
+
export { helpers_getAsset as getAsset, helpers_getExcerpt as getExcerpt, helpers_getLink as getLink, helpers_getNavClass as getNavClass, helpers_getParamLink as getParamLink, helpers_getSitemapLink as getSitemapLink, helpers_list as list, helpers_markdown as markdown, helpers_nextItem as nextItem, helpers_prevItem as prevItem };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare function getRandomProjectNames(length: number): string[];
|
|
124
|
+
type WriteOutputParams = {
|
|
125
|
+
basePath: string;
|
|
126
|
+
fileName: string;
|
|
127
|
+
output: string;
|
|
128
|
+
};
|
|
129
|
+
declare function writeOutput({ basePath, fileName, output, }: WriteOutputParams): Promise<void>;
|
|
130
|
+
declare function toMarkdownFile({ content, ...frontMatter }: {
|
|
131
|
+
content: string;
|
|
132
|
+
frontMatter: Record<string, unknown>;
|
|
133
|
+
}): string;
|
|
134
|
+
type GeneratePostParams = {
|
|
135
|
+
index: number;
|
|
136
|
+
template?: string;
|
|
137
|
+
slug?: string;
|
|
138
|
+
withBlocks?: boolean;
|
|
139
|
+
};
|
|
140
|
+
declare function generatePost({ index, template, slug, withBlocks, }: GeneratePostParams): {
|
|
141
|
+
title: string;
|
|
142
|
+
template: string;
|
|
143
|
+
created_at: Date;
|
|
144
|
+
slug: string;
|
|
145
|
+
cover: {
|
|
146
|
+
url: string;
|
|
147
|
+
caption: string;
|
|
148
|
+
attribution: {
|
|
149
|
+
text: string;
|
|
150
|
+
link: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
fileName: string;
|
|
154
|
+
content: string;
|
|
155
|
+
};
|
|
156
|
+
declare function generateProject({ name, index, }: {
|
|
157
|
+
name: string;
|
|
158
|
+
index: number;
|
|
159
|
+
}): {
|
|
160
|
+
title: string;
|
|
161
|
+
slug: string;
|
|
162
|
+
template: string;
|
|
163
|
+
work_date: Date;
|
|
164
|
+
homepage: string;
|
|
165
|
+
demo: string;
|
|
166
|
+
technologies: string[];
|
|
167
|
+
cover: {
|
|
168
|
+
url: string;
|
|
169
|
+
caption: string;
|
|
170
|
+
attribution: {
|
|
171
|
+
text: string;
|
|
172
|
+
link: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
fileName: string;
|
|
176
|
+
content: string;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
declare const generator_generatePost: typeof generatePost;
|
|
180
|
+
declare const generator_generateProject: typeof generateProject;
|
|
181
|
+
declare const generator_getRandomProjectNames: typeof getRandomProjectNames;
|
|
182
|
+
declare const generator_toMarkdownFile: typeof toMarkdownFile;
|
|
183
|
+
declare const generator_writeOutput: typeof writeOutput;
|
|
184
|
+
declare namespace generator {
|
|
185
|
+
export { generator_generatePost as generatePost, generator_generateProject as generateProject, generator_getRandomProjectNames as getRandomProjectNames, generator_toMarkdownFile as toMarkdownFile, generator_writeOutput as writeOutput };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { type Page, generator, getSlug, getSorter, getTemplate, helpers, load, loadJSON, loadMarkdown, paginate, render };
|