@podlite/publisher 0.0.2
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/CHANGELOG.md +10 -0
- package/LICENSE +22 -0
- package/README.md +41 -0
- package/esm/breadcrumb-plugin.d.ts +3 -0
- package/esm/breadcrumb-plugin.js +34 -0
- package/esm/breadcrumb-plugin.js.map +1 -0
- package/esm/constants.d.ts +27 -0
- package/esm/constants.js +28 -0
- package/esm/constants.js.map +1 -0
- package/esm/images-plugin.d.ts +3 -0
- package/esm/images-plugin.js +60 -0
- package/esm/images-plugin.js.map +1 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +5 -0
- package/esm/index.js.map +1 -0
- package/esm/links-plugin.d.ts +3 -0
- package/esm/links-plugin.js +87 -0
- package/esm/links-plugin.js.map +1 -0
- package/esm/node-utils.d.ts +50 -0
- package/esm/node-utils.js +376 -0
- package/esm/node-utils.js.map +1 -0
- package/esm/plugins.d.ts +138 -0
- package/esm/plugins.js +147 -0
- package/esm/plugins.js.map +1 -0
- package/esm/pubdate-plugin.d.ts +9 -0
- package/esm/pubdate-plugin.js +137 -0
- package/esm/pubdate-plugin.js.map +1 -0
- package/esm/react-plugin.d.ts +3 -0
- package/esm/react-plugin.js +109 -0
- package/esm/react-plugin.js.map +1 -0
- package/esm/shared.d.ts +36 -0
- package/esm/shared.js +157 -0
- package/esm/shared.js.map +1 -0
- package/esm/site-data-plugin.d.ts +25 -0
- package/esm/site-data-plugin.js +135 -0
- package/esm/site-data-plugin.js.map +1 -0
- package/esm/state-version-plugin.d.ts +3 -0
- package/esm/state-version-plugin.js +23 -0
- package/esm/state-version-plugin.js.map +1 -0
- package/esm/template-plugin.d.ts +3 -0
- package/esm/template-plugin.js +10 -0
- package/esm/template-plugin.js.map +1 -0
- package/esm/terms-index-plugin.d.ts +5 -0
- package/esm/terms-index-plugin.js +108 -0
- package/esm/terms-index-plugin.js.map +1 -0
- package/lib/breadcrumb-plugin.d.ts +3 -0
- package/lib/breadcrumb-plugin.js +36 -0
- package/lib/constants.d.ts +27 -0
- package/lib/constants.js +34 -0
- package/lib/images-plugin.d.ts +3 -0
- package/lib/images-plugin.js +84 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +17 -0
- package/lib/links-plugin.d.ts +3 -0
- package/lib/links-plugin.js +89 -0
- package/lib/node-utils.d.ts +50 -0
- package/lib/node-utils.js +412 -0
- package/lib/plugins.d.ts +138 -0
- package/lib/plugins.js +153 -0
- package/lib/pubdate-plugin.d.ts +9 -0
- package/lib/pubdate-plugin.js +143 -0
- package/lib/react-plugin.d.ts +3 -0
- package/lib/react-plugin.js +130 -0
- package/lib/shared.d.ts +36 -0
- package/lib/shared.js +169 -0
- package/lib/site-data-plugin.d.ts +25 -0
- package/lib/site-data-plugin.js +159 -0
- package/lib/state-version-plugin.d.ts +3 -0
- package/lib/state-version-plugin.js +44 -0
- package/lib/template-plugin.d.ts +3 -0
- package/lib/template-plugin.js +12 -0
- package/lib/terms-index-plugin.d.ts +5 -0
- package/lib/terms-index-plugin.js +129 -0
- package/package.json +52 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-data-plugin.js","sourceRoot":"","sources":["../src/site-data-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAA4D,gBAAgB,EAAE,MAAM,GAAG,CAAA;AAC9F,OAAO,MAAM,MAAM,MAAM,CAAA;AAmBzB,MAAM,MAAM,GAAG,CAAC,EACd,WAAW,GAAG,WAAW,EACzB,aAAa,GAAG,GAAG,UAAU,IAAI,UAAU,EAAE,EAC7C,UAAU,GAAG,UAAU,EACvB,QA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';
|
|
3
|
+
const version = require('../package.json').version;
|
|
4
|
+
const plugin = () => {
|
|
5
|
+
const outCtx = {};
|
|
6
|
+
let crc_sum = '';
|
|
7
|
+
const onExit = ctx => {
|
|
8
|
+
outCtx.stateVersion = CRC32.str(crc_sum) + '+v' + version;
|
|
9
|
+
return { ...ctx, ...outCtx };
|
|
10
|
+
};
|
|
11
|
+
const getStateVersion = (allREcords) => {
|
|
12
|
+
return allREcords.reduce((prev, current) => {
|
|
13
|
+
return prev + CRC32.str(getTextContentFromNode(current.node));
|
|
14
|
+
}, '');
|
|
15
|
+
};
|
|
16
|
+
const onProcess = (recs) => {
|
|
17
|
+
crc_sum += getStateVersion(recs);
|
|
18
|
+
return recs;
|
|
19
|
+
};
|
|
20
|
+
return [onProcess, onExit];
|
|
21
|
+
};
|
|
22
|
+
export default plugin;
|
|
23
|
+
//# sourceMappingURL=state-version-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-version-plugin.js","sourceRoot":"","sources":["../src/state-version-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAExD,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAA;AAClD,MAAM,MAAM,GAAG,GAAqB,EAAE;IACpC,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE;QACnB,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAAA;QACzD,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,EAAE,CAAA;IAC9B,CAAC,CAAA;IACD,MAAM,eAAe,GAAG,CAAC,UAAU,EAAU,EAAE;QAC7C,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;YACzC,OAAO,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QAC/D,CAAC,EAAE,EAAE,CAAC,CAAA;IACR,CAAC,CAAA;IACD,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE;QAC1C,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-plugin.js","sourceRoot":"","sources":["../src/template-plugin.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAqB,EAAE;IACpC,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;IAC7C,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE;QAC1C,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { getTextContentFromNode, makeInterator, } from '@podlite/schema';
|
|
2
|
+
import { BUILT_PATH } from '../src/constants';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
const plugin = ({ built_path = BUILT_PATH }) => {
|
|
5
|
+
const outCtx = {};
|
|
6
|
+
const onExit = ctx => {
|
|
7
|
+
if (!ctx.testing) {
|
|
8
|
+
// save control.json
|
|
9
|
+
fs.writeFileSync(`${built_path}/indexTerms.json`, JSON.stringify(outCtx.indexTerms, null, 2));
|
|
10
|
+
}
|
|
11
|
+
return { ...ctx, ...outCtx };
|
|
12
|
+
};
|
|
13
|
+
const isNodeContainsX = (node) => {
|
|
14
|
+
let isExistsDocBlocks = false;
|
|
15
|
+
const rules = {
|
|
16
|
+
'X<>': (node, ctx, interator) => {
|
|
17
|
+
// skip root block
|
|
18
|
+
isExistsDocBlocks = true;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
makeInterator(rules)(node, {});
|
|
22
|
+
return isExistsDocBlocks;
|
|
23
|
+
};
|
|
24
|
+
function findNearest(arr, index, checkFn) {
|
|
25
|
+
const leftPart = arr.slice(0, index).reverse();
|
|
26
|
+
const rightPart = arr.slice(index + 1);
|
|
27
|
+
const findIndex = (part) => {
|
|
28
|
+
const foundIndex = part.findIndex(item => checkFn(item));
|
|
29
|
+
return foundIndex !== -1 ? foundIndex : null;
|
|
30
|
+
};
|
|
31
|
+
const left = findIndex(leftPart);
|
|
32
|
+
const right = findIndex(rightPart);
|
|
33
|
+
const found = [left != null && leftPart[left], right != null && rightPart[right]].filter(Boolean);
|
|
34
|
+
if (found.length && found.length < 2) {
|
|
35
|
+
return found[0];
|
|
36
|
+
}
|
|
37
|
+
return left < right ? leftPart[left] : rightPart[right];
|
|
38
|
+
}
|
|
39
|
+
const processNode = (node) => {
|
|
40
|
+
const res = [];
|
|
41
|
+
const rules = {
|
|
42
|
+
':block': (node, ctx, interator) => {
|
|
43
|
+
// ctx.parent = node
|
|
44
|
+
if (node.content) {
|
|
45
|
+
// provess root block content
|
|
46
|
+
return interator(node.content, { ...ctx, parent: node });
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
':para': (node, ctx, interator) => {
|
|
50
|
+
if (['root', 'pod'].includes(ctx.parent.name)) {
|
|
51
|
+
const isEmptyContent = node => getTextContentFromNode(node).match(/^\s*$/);
|
|
52
|
+
if (isNodeContainsX(node)) {
|
|
53
|
+
if (isEmptyContent(node)) {
|
|
54
|
+
const indexOfCurrentNode = ctx.parent.content.findIndex(i => i === node);
|
|
55
|
+
if (indexOfCurrentNode) {
|
|
56
|
+
//find nearest addresable block
|
|
57
|
+
const nearestBlock = findNearest(ctx.parent.content, indexOfCurrentNode, node => {
|
|
58
|
+
// check if node is string
|
|
59
|
+
if (typeof node !== 'string' && 'type' in node) {
|
|
60
|
+
return node.type === 'block';
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
});
|
|
64
|
+
// set parent nearest addresable block
|
|
65
|
+
if (node.content) {
|
|
66
|
+
// provess root block content
|
|
67
|
+
return interator(node.content, { ...ctx, parent: nearestBlock });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (node.content) {
|
|
74
|
+
// provess root block content
|
|
75
|
+
return interator(node.content, { ...ctx, parent: ctx.parent });
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
'X<>': (node, ctx) => {
|
|
79
|
+
res.push({ xnode: node, parent: ctx.parent });
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
makeInterator(rules)(node, {});
|
|
83
|
+
return res;
|
|
84
|
+
};
|
|
85
|
+
const onProcess = (recs) => {
|
|
86
|
+
const res = recs.map(item => {
|
|
87
|
+
const terms = processNode(item.node);
|
|
88
|
+
const termWithUrl = terms.map(({ xnode, parent }) => {
|
|
89
|
+
const urlParts = [item.publishUrl];
|
|
90
|
+
if (parent && typeof parent !== 'string' && 'id' in parent) {
|
|
91
|
+
urlParts.push(parent.id);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
xnode,
|
|
95
|
+
url: urlParts.join('#'),
|
|
96
|
+
title: item.title,
|
|
97
|
+
subtitle: item.subtitle,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
outCtx.indexTerms = [...(outCtx.indexTerms || []), ...termWithUrl].filter(x => Boolean(x.xnode.entry));
|
|
101
|
+
return { ...item };
|
|
102
|
+
});
|
|
103
|
+
return res;
|
|
104
|
+
};
|
|
105
|
+
return [onProcess, onExit];
|
|
106
|
+
};
|
|
107
|
+
export default plugin;
|
|
108
|
+
//# sourceMappingURL=terms-index-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms-index-plugin.js","sourceRoot":"","sources":["../src/terms-index-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,sBAAsB,EACtB,aAAa,GAMd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AAExB,MAAM,MAAM,GAAG,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,EAAoB,EAAE;IAC/D,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE;QACnB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YAChB,oBAAoB;YACpB,EAAE,CAAC,aAAa,CAAC,GAAG,UAAU,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;SAC9F;QACD,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,EAAE,CAAA;IAC9B,CAAC,CAAA;IACD,MAAM,eAAe,GAAG,CAAC,IAAa,EAAE,EAAE;QACxC,IAAI,iBAAiB,GAAG,KAAK,CAAA;QAE7B,MAAM,KAAK,GAAG;YACZ,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE;gBAC9B,kBAAkB;gBAClB,iBAAiB,GAAG,IAAI,CAAA;YAC1B,CAAC;SACF,CAAA;QACD,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAC9B,OAAO,iBAAiB,CAAA;IAC1B,CAAC,CAAA;IACD,SAAS,WAAW,CAAC,GAAc,EAAE,KAA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AAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;YACtG,OAAO,EAAE,GAAG,IAAI,EAAE,CAAA;QACpB,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,CAAA;IACZ,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AACD,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const plugin = () => {
|
|
4
|
+
const outCtx = {};
|
|
5
|
+
const cacheBreadcrumb = {};
|
|
6
|
+
const onExit = ctx => ({ ...ctx, ...outCtx });
|
|
7
|
+
const getBreadcrumb = (url, recs) => {
|
|
8
|
+
if (cacheBreadcrumb[url]) {
|
|
9
|
+
return cacheBreadcrumb[url];
|
|
10
|
+
}
|
|
11
|
+
const currentCrumb = [];
|
|
12
|
+
const currentSlug = url.split('/').slice(1);
|
|
13
|
+
if (currentSlug.length > 1) {
|
|
14
|
+
const parentSlug = currentSlug.slice(0, -1);
|
|
15
|
+
const parentUrl = '/' + parentSlug.join('/');
|
|
16
|
+
currentCrumb.push(...getBreadcrumb(parentUrl, recs));
|
|
17
|
+
}
|
|
18
|
+
const selectedItem = recs.find(item => item.publishUrl === url);
|
|
19
|
+
if (selectedItem) {
|
|
20
|
+
currentCrumb.push({ title: selectedItem.title, publishUrl: selectedItem.publishUrl });
|
|
21
|
+
}
|
|
22
|
+
cacheBreadcrumb[url] = currentCrumb;
|
|
23
|
+
return currentCrumb;
|
|
24
|
+
};
|
|
25
|
+
const onProcess = (recs) => {
|
|
26
|
+
recs.forEach(item => {
|
|
27
|
+
const breadcrumb = getBreadcrumb(item.publishUrl, recs);
|
|
28
|
+
item.pluginsData = item.pluginsData || {};
|
|
29
|
+
item.pluginsData.breadcrumb = breadcrumb;
|
|
30
|
+
});
|
|
31
|
+
return recs;
|
|
32
|
+
};
|
|
33
|
+
return [onProcess, onExit];
|
|
34
|
+
};
|
|
35
|
+
exports.default = plugin;
|
|
36
|
+
//# sourceMappingURL=breadcrumb-plugin.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PodNode } from '@podlite/schema';
|
|
2
|
+
export declare const POSTS_PATH: string;
|
|
3
|
+
export declare const INDEX_PATH: string;
|
|
4
|
+
export declare const BUILT_PATH: string;
|
|
5
|
+
export declare const DATA_PATH: string;
|
|
6
|
+
export declare const IMAGE_LIB: string;
|
|
7
|
+
export declare const COMPONENTS_LIB: string;
|
|
8
|
+
export declare const STYLES_LIB: string;
|
|
9
|
+
export declare const PAGES_FILE_PATH: string;
|
|
10
|
+
export declare const ASSETS_PATH: string;
|
|
11
|
+
export declare const PUBLIC_PATH: string;
|
|
12
|
+
export declare type SiteInfo = {
|
|
13
|
+
postsPerPage: 4;
|
|
14
|
+
favicon: string;
|
|
15
|
+
url: 'http://example.com';
|
|
16
|
+
title: 'Example';
|
|
17
|
+
globalStyles?: string;
|
|
18
|
+
node: PodNode;
|
|
19
|
+
footer: PodNode;
|
|
20
|
+
gtmId?: string;
|
|
21
|
+
redirects: {
|
|
22
|
+
source: string;
|
|
23
|
+
destination: string;
|
|
24
|
+
statusCode: number;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
export declare const defaultIndexPage = "\n=begin pod \n= :favicon<./favicon.png>\n= :puburl<http://example.com>\n\n=TITLE \uD83D\uDCDD How to make a great post\n\n=para \nHey, this is a test page!\n\n\nPowered by podlite.\n\n=end pod\n";
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defaultIndexPage = exports.PUBLIC_PATH = exports.ASSETS_PATH = exports.PAGES_FILE_PATH = exports.STYLES_LIB = exports.COMPONENTS_LIB = exports.IMAGE_LIB = exports.DATA_PATH = exports.BUILT_PATH = exports.INDEX_PATH = exports.POSTS_PATH = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
// export const POSTS_PATH = path.join(process.cwd(), "/data")
|
|
9
|
+
exports.POSTS_PATH = process.env.POSTS_PATH || path_1.default.join(process.cwd(), '/pub');
|
|
10
|
+
exports.INDEX_PATH = process.env.INDEX_PATH || 'index.pod6';
|
|
11
|
+
exports.BUILT_PATH = path_1.default.join(process.cwd(), '/built');
|
|
12
|
+
exports.DATA_PATH = path_1.default.join(process.cwd(), '/built/data.json');
|
|
13
|
+
exports.IMAGE_LIB = path_1.default.join(process.cwd(), '/built/images.ts');
|
|
14
|
+
exports.COMPONENTS_LIB = path_1.default.join(process.cwd(), '/built/components.ts');
|
|
15
|
+
exports.STYLES_LIB = path_1.default.join(process.cwd(), '/built/styles.css');
|
|
16
|
+
exports.PAGES_FILE_PATH = path_1.default.join(process.cwd());
|
|
17
|
+
exports.ASSETS_PATH = path_1.default.join(process.cwd(), '/public/assets');
|
|
18
|
+
exports.PUBLIC_PATH = path_1.default.join(process.cwd(), '/public');
|
|
19
|
+
exports.defaultIndexPage = `
|
|
20
|
+
=begin pod
|
|
21
|
+
= :favicon<./favicon.png>
|
|
22
|
+
= :puburl<http://example.com>
|
|
23
|
+
|
|
24
|
+
=TITLE 📝 How to make a great post
|
|
25
|
+
|
|
26
|
+
=para
|
|
27
|
+
Hey, this is a test page!
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Powered by podlite.
|
|
31
|
+
|
|
32
|
+
=end pod
|
|
33
|
+
`;
|
|
34
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const schema_1 = require("@podlite/schema");
|
|
26
|
+
const constants_1 = require("./constants");
|
|
27
|
+
const path_1 = __importDefault(require("path"));
|
|
28
|
+
const fs = __importStar(require("fs"));
|
|
29
|
+
const node_utils_1 = require("./node-utils");
|
|
30
|
+
const plugin = () => {
|
|
31
|
+
const outCtx = {};
|
|
32
|
+
const imagesMap = new Map();
|
|
33
|
+
const onExit = ctx => {
|
|
34
|
+
if (!ctx.testing) {
|
|
35
|
+
// process Images
|
|
36
|
+
let libFileContent = '';
|
|
37
|
+
for (const key of imagesMap.keys()) {
|
|
38
|
+
const variable_name = imagesMap.get(key);
|
|
39
|
+
if (!fs.existsSync(key)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
libFileContent += `import ${variable_name} from "${key}"
|
|
43
|
+
export { ${variable_name} }
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
libFileContent += `
|
|
47
|
+
export default {}
|
|
48
|
+
`;
|
|
49
|
+
fs.writeFileSync(constants_1.IMAGE_LIB, libFileContent, 'utf8');
|
|
50
|
+
}
|
|
51
|
+
return { ...ctx, ...outCtx, ...{ imagesMap: Object.fromEntries(imagesMap) } };
|
|
52
|
+
};
|
|
53
|
+
const processNode = (node, file) => {
|
|
54
|
+
const rules = {
|
|
55
|
+
':image': node => {
|
|
56
|
+
// process copy files to assets
|
|
57
|
+
// '../assets/'
|
|
58
|
+
const { path } = (0, node_utils_1.getPathToOpen)(node.src, file);
|
|
59
|
+
const { name, ext, dir } = path_1.default.parse(path);
|
|
60
|
+
const variable_name = 'i' + path.split('/').slice(1).join('_').replace(/\W+/g, '_').toLowerCase();
|
|
61
|
+
const newFileName = `${variable_name}${ext}`;
|
|
62
|
+
const dstFilename = constants_1.ASSETS_PATH + '/' + newFileName;
|
|
63
|
+
imagesMap.set(path, variable_name);
|
|
64
|
+
return { ...node, src: variable_name };
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
return (0, schema_1.makeInterator)(rules)(node, {});
|
|
68
|
+
};
|
|
69
|
+
const onProcess = (recs) => {
|
|
70
|
+
const res = recs.map(item => {
|
|
71
|
+
const node = processNode(item.node, item.file);
|
|
72
|
+
// process images inside description
|
|
73
|
+
let extra = {};
|
|
74
|
+
if (item.description) {
|
|
75
|
+
extra.description = processNode(item.description, item.file);
|
|
76
|
+
}
|
|
77
|
+
return { ...item, node, ...extra };
|
|
78
|
+
});
|
|
79
|
+
return res;
|
|
80
|
+
};
|
|
81
|
+
return [onProcess, onExit];
|
|
82
|
+
};
|
|
83
|
+
exports.default = plugin;
|
|
84
|
+
//# sourceMappingURL=images-plugin.js.map
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./plugins"), exports);
|
|
14
|
+
__exportStar(require("./shared"), exports);
|
|
15
|
+
__exportStar(require("./node-utils"), exports);
|
|
16
|
+
__exportStar(require("./state-version-plugin"), exports);
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_1 = require("@podlite/schema");
|
|
4
|
+
const node_utils_1 = require("./node-utils");
|
|
5
|
+
const plugin = () => {
|
|
6
|
+
const outCtx = {};
|
|
7
|
+
const docsMap = new Map();
|
|
8
|
+
const onExit = ctx => ({ ...ctx, ...outCtx });
|
|
9
|
+
const processNode = (node, srcfile) => {
|
|
10
|
+
const rules = {
|
|
11
|
+
'L<>': node => {
|
|
12
|
+
const { content, meta } = node;
|
|
13
|
+
const link = meta ? meta : (0, schema_1.getTextContentFromNode)(content);
|
|
14
|
+
const r = link.match(/doc:\s*(?<path>(.+))\s*$/);
|
|
15
|
+
if (r?.groups?.path) {
|
|
16
|
+
const docLink = r.groups.path;
|
|
17
|
+
const { isRemote } = (0, node_utils_1.getPathToOpen)(docLink, srcfile);
|
|
18
|
+
if (isRemote) {
|
|
19
|
+
return node;
|
|
20
|
+
}
|
|
21
|
+
let title;
|
|
22
|
+
let url;
|
|
23
|
+
if (!docsMap.has(docLink)) {
|
|
24
|
+
console.error(`doc: ${docLink} not found`);
|
|
25
|
+
title = `doc: ${docLink} not found`;
|
|
26
|
+
url = `doc: ${docLink} not found`;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const { title: title1, url: url1 } = docsMap.get(docLink);
|
|
30
|
+
title = title1;
|
|
31
|
+
url = url1;
|
|
32
|
+
}
|
|
33
|
+
const newContent = {
|
|
34
|
+
type: 'text',
|
|
35
|
+
value: `${title}`,
|
|
36
|
+
};
|
|
37
|
+
const updated = meta ? { meta: url } : { content: newContent, meta: url };
|
|
38
|
+
return { ...node, ...updated };
|
|
39
|
+
}
|
|
40
|
+
return node;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return (0, schema_1.makeInterator)(rules)(node, {});
|
|
44
|
+
};
|
|
45
|
+
const onProcess = (recs) => {
|
|
46
|
+
// const collectlinksMap = makeLinksMap(recs)
|
|
47
|
+
// collects docsMap map doc: to file
|
|
48
|
+
for (const item of recs) {
|
|
49
|
+
// get =TITLE
|
|
50
|
+
const handler = node => {
|
|
51
|
+
const conf = (0, schema_1.makeAttrs)(node, {});
|
|
52
|
+
const title = (0, schema_1.getTextContentFromNode)(node).trim();
|
|
53
|
+
if (conf.exists('id')) {
|
|
54
|
+
const id = conf.getFirstValue('id');
|
|
55
|
+
if (id) {
|
|
56
|
+
docsMap.set(id, { file: item.file, title, url: item.publishUrl });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
docsMap.set(title, { file: item.file, title, url: item.publishUrl });
|
|
60
|
+
};
|
|
61
|
+
(0, schema_1.makeInterator)({
|
|
62
|
+
NAME: handler,
|
|
63
|
+
TITLE: handler,
|
|
64
|
+
})(item.node, {});
|
|
65
|
+
}
|
|
66
|
+
// convert all doc: links to file:: links
|
|
67
|
+
const docToFileLinksConverted = recs.map(item => {
|
|
68
|
+
const node = processNode(item.node, item.file);
|
|
69
|
+
// process images inside description
|
|
70
|
+
let extra = {};
|
|
71
|
+
if (item.description) {
|
|
72
|
+
extra.description = processNode(item.description, item.file);
|
|
73
|
+
}
|
|
74
|
+
// process file header and footer
|
|
75
|
+
const { footer, header } = item;
|
|
76
|
+
if (footer) {
|
|
77
|
+
extra.footer = processNode(footer, item.file);
|
|
78
|
+
}
|
|
79
|
+
if (header) {
|
|
80
|
+
extra.header = processNode(header, item.file);
|
|
81
|
+
}
|
|
82
|
+
return { ...item, node, ...extra };
|
|
83
|
+
});
|
|
84
|
+
return (0, node_utils_1.convertFileLinksToUrl)(docToFileLinksConverted);
|
|
85
|
+
};
|
|
86
|
+
return [onProcess, onExit];
|
|
87
|
+
};
|
|
88
|
+
exports.default = plugin;
|
|
89
|
+
//# sourceMappingURL=links-plugin.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PodliteDocument, PodNode, RootBlock } from '@podlite/schema';
|
|
2
|
+
import { publishRecord, pubRecord } from '.';
|
|
3
|
+
export declare const getPathToOpen: (filepath: any, parentDocPath: any) => {
|
|
4
|
+
isRemote: boolean;
|
|
5
|
+
path: any;
|
|
6
|
+
};
|
|
7
|
+
export declare const makeLinksMap: (records: publishRecord[]) => {
|
|
8
|
+
[link: string]: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const convertFileLinksToUrl: (records: publishRecord[], additinalMap?: {}) => publishRecord[];
|
|
11
|
+
export declare function parseFiles(path: string): pubRecord[];
|
|
12
|
+
declare const PARSER_TYPES: {
|
|
13
|
+
MARKDOWN: "markdown";
|
|
14
|
+
PODLITE: "podlite";
|
|
15
|
+
DEFAULT: "default";
|
|
16
|
+
ERROR: "error";
|
|
17
|
+
};
|
|
18
|
+
declare const MIME_TYPES_EXTENSIONS: {
|
|
19
|
+
'text/podlite': readonly [".podlite", ".pod6"];
|
|
20
|
+
'text/markdown': readonly [".md", ".markdown"];
|
|
21
|
+
'text/plain': readonly [".txt"];
|
|
22
|
+
'audio/mpeg': readonly [".mp3"];
|
|
23
|
+
};
|
|
24
|
+
declare type PartserTypes = typeof PARSER_TYPES[keyof typeof PARSER_TYPES];
|
|
25
|
+
declare type MimeTypes = keyof typeof MIME_TYPES_EXTENSIONS;
|
|
26
|
+
export declare function getParserTypeforFile(filePath: string, mime?: MimeTypes): PartserTypes;
|
|
27
|
+
export declare function parseFile(filePath: string, fileContent?: string, mime?: MimeTypes): RootBlock;
|
|
28
|
+
export declare function getDocumentAttributes(node: PodliteDocument): {
|
|
29
|
+
header: any;
|
|
30
|
+
title: string;
|
|
31
|
+
description: string;
|
|
32
|
+
subtitle: any;
|
|
33
|
+
author: any;
|
|
34
|
+
footer: string;
|
|
35
|
+
puburl: any;
|
|
36
|
+
pubdate: any;
|
|
37
|
+
};
|
|
38
|
+
export declare function getPublishAttributes(node: PodNode): {
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
subtitle: any;
|
|
42
|
+
author: any;
|
|
43
|
+
footer: string;
|
|
44
|
+
puburl: any;
|
|
45
|
+
pubdate: any;
|
|
46
|
+
};
|
|
47
|
+
export declare function processFile(f: string, content?: string, mime?: MimeTypes): publishRecord;
|
|
48
|
+
export declare function parseSources(path: string): publishRecord[];
|
|
49
|
+
export declare function streamWriteArray(array: any[], outputPath: any): Promise<unknown>;
|
|
50
|
+
export {};
|