@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
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2021-2024 Aliaksandr Zahatski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @podlite/publisher
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[](https://podlite.org)
|
|
6
|
+
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
**Podlite is a lightweight block-based markup language designed for flexibility and ease of use.**
|
|
10
|
+
|
|
11
|
+
Unbound by any specific domain, programming language, or concept, Podlite stands out as a universal markup language. It's versatile enough to be successfully implemented across various development fields, from web development to scientific research.
|
|
12
|
+
|
|
13
|
+
Podlite is not limited to any specific application domain, programming language, or concept.
|
|
14
|
+
|
|
15
|
+
In addition, the support for Markdown markup as a standard block adds convenience and allows for the use of familiar syntax for text formatting.
|
|
16
|
+
|
|
17
|
+
One of the key features of Podlite is its extensibility. This allows for defining unique and domain-specific blocks and expanding the language's functionality according to the requirements of your project.
|
|
18
|
+
|
|
19
|
+
Its flexibility makes it an ideal tool for creating documentation, blogs, educational materials, and much more.
|
|
20
|
+
|
|
21
|
+
Podlite aims to provide users with a means for creativity and expressing ideas in a structured form, while ensuring ease of use and high flexibility in content creation.
|
|
22
|
+
|
|
23
|
+
## Useful links
|
|
24
|
+
|
|
25
|
+
📖 _Project site_: [podlite.org](https://podlite.org)
|
|
26
|
+
|
|
27
|
+
📌 _Github_: [github.com/podlite](https://github.com/podlite/) 🤩
|
|
28
|
+
|
|
29
|
+
🖥️ _Online editor_: [pod6.in](https://pod6.in/)
|
|
30
|
+
|
|
31
|
+
🖥️ _Desktop editor/viewer_: [github.com/podlite/podlite-desktop](https://github.com/podlite/podlite-desktop) - the viewer and editor of `.podlite` and `.pod6` files for Windows, Linux and Mac.
|
|
32
|
+
|
|
33
|
+
📚 _Podlite for web_ - static site generator: [github.com/podlite/podlite-web](https://github.com/podlite/podlite-web)
|
|
34
|
+
|
|
35
|
+
## AUTHOR
|
|
36
|
+
|
|
37
|
+
Copyright (c) 2021-2024 Aliaksandr Zahatski
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
Released under a MIT License.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const plugin = () => {
|
|
2
|
+
const outCtx = {};
|
|
3
|
+
const cacheBreadcrumb = {};
|
|
4
|
+
const onExit = ctx => ({ ...ctx, ...outCtx });
|
|
5
|
+
const getBreadcrumb = (url, recs) => {
|
|
6
|
+
if (cacheBreadcrumb[url]) {
|
|
7
|
+
return cacheBreadcrumb[url];
|
|
8
|
+
}
|
|
9
|
+
const currentCrumb = [];
|
|
10
|
+
const currentSlug = url.split('/').slice(1);
|
|
11
|
+
if (currentSlug.length > 1) {
|
|
12
|
+
const parentSlug = currentSlug.slice(0, -1);
|
|
13
|
+
const parentUrl = '/' + parentSlug.join('/');
|
|
14
|
+
currentCrumb.push(...getBreadcrumb(parentUrl, recs));
|
|
15
|
+
}
|
|
16
|
+
const selectedItem = recs.find(item => item.publishUrl === url);
|
|
17
|
+
if (selectedItem) {
|
|
18
|
+
currentCrumb.push({ title: selectedItem.title, publishUrl: selectedItem.publishUrl });
|
|
19
|
+
}
|
|
20
|
+
cacheBreadcrumb[url] = currentCrumb;
|
|
21
|
+
return currentCrumb;
|
|
22
|
+
};
|
|
23
|
+
const onProcess = (recs) => {
|
|
24
|
+
recs.forEach(item => {
|
|
25
|
+
const breadcrumb = getBreadcrumb(item.publishUrl, recs);
|
|
26
|
+
item.pluginsData = item.pluginsData || {};
|
|
27
|
+
item.pluginsData.breadcrumb = breadcrumb;
|
|
28
|
+
});
|
|
29
|
+
return recs;
|
|
30
|
+
};
|
|
31
|
+
return [onProcess, onExit];
|
|
32
|
+
};
|
|
33
|
+
export default plugin;
|
|
34
|
+
//# sourceMappingURL=breadcrumb-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumb-plugin.js","sourceRoot":"","sources":["../src/breadcrumb-plugin.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAqB,EAAE;IACpC,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,MAAM,eAAe,GAAsE,EAAE,CAAA;IAC7F,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;IAC7C,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,IAAqB,EAAE,EAAE;QAC3D,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO,eAAe,CAAC,GAAG,CAAC,CAAA;SAC5B;QACD,MAAM,YAAY,GAAmD,EAAE,CAAA;QAEvE,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC3C,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;YAC3C,MAAM,SAAS,GAAG,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC5C,YAAY,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAA;SACrD;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,GAAG,CAAC,CAAA;QAC/D,IAAI,YAAY,EAAE;YAChB,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,CAAC,UAAU,EAAE,CAAC,CAAA;SACtF;QACD,eAAe,CAAC,GAAG,CAAC,GAAG,YAAY,CAAA;QACnC,OAAO,YAAY,CAAA;IACrB,CAAC,CAAA;IAED,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAClB,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;YACvD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAA;YACzC,IAAI,CAAC,WAAW,CAAC,UAAU,GAAG,UAAU,CAAA;QAC1C,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -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/esm/constants.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
// export const POSTS_PATH = path.join(process.cwd(), "/data")
|
|
3
|
+
export const POSTS_PATH = process.env.POSTS_PATH || path.join(process.cwd(), '/pub');
|
|
4
|
+
export const INDEX_PATH = process.env.INDEX_PATH || 'index.pod6';
|
|
5
|
+
export const BUILT_PATH = path.join(process.cwd(), '/built');
|
|
6
|
+
export const DATA_PATH = path.join(process.cwd(), '/built/data.json');
|
|
7
|
+
export const IMAGE_LIB = path.join(process.cwd(), '/built/images.ts');
|
|
8
|
+
export const COMPONENTS_LIB = path.join(process.cwd(), '/built/components.ts');
|
|
9
|
+
export const STYLES_LIB = path.join(process.cwd(), '/built/styles.css');
|
|
10
|
+
export const PAGES_FILE_PATH = path.join(process.cwd());
|
|
11
|
+
export const ASSETS_PATH = path.join(process.cwd(), '/public/assets');
|
|
12
|
+
export const PUBLIC_PATH = path.join(process.cwd(), '/public');
|
|
13
|
+
export const defaultIndexPage = `
|
|
14
|
+
=begin pod
|
|
15
|
+
= :favicon<./favicon.png>
|
|
16
|
+
= :puburl<http://example.com>
|
|
17
|
+
|
|
18
|
+
=TITLE 📝 How to make a great post
|
|
19
|
+
|
|
20
|
+
=para
|
|
21
|
+
Hey, this is a test page!
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Powered by podlite.
|
|
25
|
+
|
|
26
|
+
=end pod
|
|
27
|
+
`;
|
|
28
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,8DAA8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAA;AACpF,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,YAAY,CAAA;AAEhE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAA;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAA;AACrE,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAA;AACrE,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,sBAAsB,CAAC,CAAA;AAC9E,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,mBAAmB,CAAC,CAAA;AAEvE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAA;AACrE,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAA;AAkB9D,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;CAc/B,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { makeInterator } from '@podlite/schema';
|
|
2
|
+
import { ASSETS_PATH, IMAGE_LIB } from './constants';
|
|
3
|
+
import pathMod from 'path';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import { getPathToOpen } from './node-utils';
|
|
6
|
+
const plugin = () => {
|
|
7
|
+
const outCtx = {};
|
|
8
|
+
const imagesMap = new Map();
|
|
9
|
+
const onExit = ctx => {
|
|
10
|
+
if (!ctx.testing) {
|
|
11
|
+
// process Images
|
|
12
|
+
let libFileContent = '';
|
|
13
|
+
for (const key of imagesMap.keys()) {
|
|
14
|
+
const variable_name = imagesMap.get(key);
|
|
15
|
+
if (!fs.existsSync(key)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
libFileContent += `import ${variable_name} from "${key}"
|
|
19
|
+
export { ${variable_name} }
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
libFileContent += `
|
|
23
|
+
export default {}
|
|
24
|
+
`;
|
|
25
|
+
fs.writeFileSync(IMAGE_LIB, libFileContent, 'utf8');
|
|
26
|
+
}
|
|
27
|
+
return { ...ctx, ...outCtx, ...{ imagesMap: Object.fromEntries(imagesMap) } };
|
|
28
|
+
};
|
|
29
|
+
const processNode = (node, file) => {
|
|
30
|
+
const rules = {
|
|
31
|
+
':image': node => {
|
|
32
|
+
// process copy files to assets
|
|
33
|
+
// '../assets/'
|
|
34
|
+
const { path } = getPathToOpen(node.src, file);
|
|
35
|
+
const { name, ext, dir } = pathMod.parse(path);
|
|
36
|
+
const variable_name = 'i' + path.split('/').slice(1).join('_').replace(/\W+/g, '_').toLowerCase();
|
|
37
|
+
const newFileName = `${variable_name}${ext}`;
|
|
38
|
+
const dstFilename = ASSETS_PATH + '/' + newFileName;
|
|
39
|
+
imagesMap.set(path, variable_name);
|
|
40
|
+
return { ...node, src: variable_name };
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return makeInterator(rules)(node, {});
|
|
44
|
+
};
|
|
45
|
+
const onProcess = (recs) => {
|
|
46
|
+
const res = recs.map(item => {
|
|
47
|
+
const node = processNode(item.node, item.file);
|
|
48
|
+
// process images inside description
|
|
49
|
+
let extra = {};
|
|
50
|
+
if (item.description) {
|
|
51
|
+
extra.description = processNode(item.description, item.file);
|
|
52
|
+
}
|
|
53
|
+
return { ...item, node, ...extra };
|
|
54
|
+
});
|
|
55
|
+
return res;
|
|
56
|
+
};
|
|
57
|
+
return [onProcess, onExit];
|
|
58
|
+
};
|
|
59
|
+
export default plugin;
|
|
60
|
+
//# sourceMappingURL=images-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images-plugin.js","sourceRoot":"","sources":["../src/images-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAW,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,OAAO,MAAM,MAAM,CAAA;AAC1B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5C,MAAM,MAAM,GAAG,GAAqB,EAAE;IACpC,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAA;IAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE;QACnB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YAChB,iBAAiB;YACjB,IAAI,cAAc,GAAG,EAAE,CAAA;YACvB,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE;gBAClC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I,EAAE,GAAG,EAAE,aAAa,EAAE,CAAA;YACxC,CAAC;SACF,CAAA;QACD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACvC,CAAC,CAAA;IACD,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;YAC9C,oCAAoC;YACpC,IAAI,KAAK,GAAG,EAA+B,CAAA;YAC3C,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;aAC7D;YAED,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,CAAA;QACpC,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,CAAA;IACZ,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/esm/index.d.ts
ADDED
package/esm/index.js
ADDED
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { getTextContentFromNode, makeAttrs, makeInterator } from '@podlite/schema';
|
|
2
|
+
import { convertFileLinksToUrl, getPathToOpen } from './node-utils';
|
|
3
|
+
const plugin = () => {
|
|
4
|
+
const outCtx = {};
|
|
5
|
+
const docsMap = new Map();
|
|
6
|
+
const onExit = ctx => ({ ...ctx, ...outCtx });
|
|
7
|
+
const processNode = (node, srcfile) => {
|
|
8
|
+
const rules = {
|
|
9
|
+
'L<>': node => {
|
|
10
|
+
const { content, meta } = node;
|
|
11
|
+
const link = meta ? meta : getTextContentFromNode(content);
|
|
12
|
+
const r = link.match(/doc:\s*(?<path>(.+))\s*$/);
|
|
13
|
+
if (r?.groups?.path) {
|
|
14
|
+
const docLink = r.groups.path;
|
|
15
|
+
const { isRemote } = getPathToOpen(docLink, srcfile);
|
|
16
|
+
if (isRemote) {
|
|
17
|
+
return node;
|
|
18
|
+
}
|
|
19
|
+
let title;
|
|
20
|
+
let url;
|
|
21
|
+
if (!docsMap.has(docLink)) {
|
|
22
|
+
console.error(`doc: ${docLink} not found`);
|
|
23
|
+
title = `doc: ${docLink} not found`;
|
|
24
|
+
url = `doc: ${docLink} not found`;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const { title: title1, url: url1 } = docsMap.get(docLink);
|
|
28
|
+
title = title1;
|
|
29
|
+
url = url1;
|
|
30
|
+
}
|
|
31
|
+
const newContent = {
|
|
32
|
+
type: 'text',
|
|
33
|
+
value: `${title}`,
|
|
34
|
+
};
|
|
35
|
+
const updated = meta ? { meta: url } : { content: newContent, meta: url };
|
|
36
|
+
return { ...node, ...updated };
|
|
37
|
+
}
|
|
38
|
+
return node;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
return makeInterator(rules)(node, {});
|
|
42
|
+
};
|
|
43
|
+
const onProcess = (recs) => {
|
|
44
|
+
// const collectlinksMap = makeLinksMap(recs)
|
|
45
|
+
// collects docsMap map doc: to file
|
|
46
|
+
for (const item of recs) {
|
|
47
|
+
// get =TITLE
|
|
48
|
+
const handler = node => {
|
|
49
|
+
const conf = makeAttrs(node, {});
|
|
50
|
+
const title = getTextContentFromNode(node).trim();
|
|
51
|
+
if (conf.exists('id')) {
|
|
52
|
+
const id = conf.getFirstValue('id');
|
|
53
|
+
if (id) {
|
|
54
|
+
docsMap.set(id, { file: item.file, title, url: item.publishUrl });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
docsMap.set(title, { file: item.file, title, url: item.publishUrl });
|
|
58
|
+
};
|
|
59
|
+
makeInterator({
|
|
60
|
+
NAME: handler,
|
|
61
|
+
TITLE: handler,
|
|
62
|
+
})(item.node, {});
|
|
63
|
+
}
|
|
64
|
+
// convert all doc: links to file:: links
|
|
65
|
+
const docToFileLinksConverted = recs.map(item => {
|
|
66
|
+
const node = processNode(item.node, item.file);
|
|
67
|
+
// process images inside description
|
|
68
|
+
let extra = {};
|
|
69
|
+
if (item.description) {
|
|
70
|
+
extra.description = processNode(item.description, item.file);
|
|
71
|
+
}
|
|
72
|
+
// process file header and footer
|
|
73
|
+
const { footer, header } = item;
|
|
74
|
+
if (footer) {
|
|
75
|
+
extra.footer = processNode(footer, item.file);
|
|
76
|
+
}
|
|
77
|
+
if (header) {
|
|
78
|
+
extra.header = processNode(header, item.file);
|
|
79
|
+
}
|
|
80
|
+
return { ...item, node, ...extra };
|
|
81
|
+
});
|
|
82
|
+
return convertFileLinksToUrl(docToFileLinksConverted);
|
|
83
|
+
};
|
|
84
|
+
return [onProcess, onExit];
|
|
85
|
+
};
|
|
86
|
+
export default plugin;
|
|
87
|
+
//# sourceMappingURL=links-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links-plugin.js","sourceRoot":"","sources":["../src/links-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,aAAa,EAAiB,MAAM,iBAAiB,CAAA;AACjG,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAA;AAEjF,MAAM,MAAM,GAAG,GAAqB,EAAE;IACpC,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,CAAA;IACzB,MAAM,MAAM,GAAG,GAAG,C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,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;SAClB;QACD,yCAAyC;QACzC,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC9C,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;YAC9C,oCAAoC;YACpC,IAAI,KAAK,GAAG,EAAmE,CAAA;YAC/E,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;aAC7D;YACD,iCAAiC;YACjC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;YAC/B,IAAI,MAAM,EAAE;gBACV,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;aAC9C;YACD,IAAI,MAAM,EAAE;gBACV,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;aAC9C;YACD,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,CAAA;QACpC,CAAC,CAAC,CAAA;QAEF,OAAO,qBAAqB,CAAC,uBAAuB,CAAC,CAAA;IACvD,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -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 {};
|