@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +22 -0
  3. package/README.md +41 -0
  4. package/esm/breadcrumb-plugin.d.ts +3 -0
  5. package/esm/breadcrumb-plugin.js +34 -0
  6. package/esm/breadcrumb-plugin.js.map +1 -0
  7. package/esm/constants.d.ts +27 -0
  8. package/esm/constants.js +28 -0
  9. package/esm/constants.js.map +1 -0
  10. package/esm/images-plugin.d.ts +3 -0
  11. package/esm/images-plugin.js +60 -0
  12. package/esm/images-plugin.js.map +1 -0
  13. package/esm/index.d.ts +4 -0
  14. package/esm/index.js +5 -0
  15. package/esm/index.js.map +1 -0
  16. package/esm/links-plugin.d.ts +3 -0
  17. package/esm/links-plugin.js +87 -0
  18. package/esm/links-plugin.js.map +1 -0
  19. package/esm/node-utils.d.ts +50 -0
  20. package/esm/node-utils.js +376 -0
  21. package/esm/node-utils.js.map +1 -0
  22. package/esm/plugins.d.ts +138 -0
  23. package/esm/plugins.js +147 -0
  24. package/esm/plugins.js.map +1 -0
  25. package/esm/pubdate-plugin.d.ts +9 -0
  26. package/esm/pubdate-plugin.js +137 -0
  27. package/esm/pubdate-plugin.js.map +1 -0
  28. package/esm/react-plugin.d.ts +3 -0
  29. package/esm/react-plugin.js +109 -0
  30. package/esm/react-plugin.js.map +1 -0
  31. package/esm/shared.d.ts +36 -0
  32. package/esm/shared.js +157 -0
  33. package/esm/shared.js.map +1 -0
  34. package/esm/site-data-plugin.d.ts +25 -0
  35. package/esm/site-data-plugin.js +135 -0
  36. package/esm/site-data-plugin.js.map +1 -0
  37. package/esm/state-version-plugin.d.ts +3 -0
  38. package/esm/state-version-plugin.js +23 -0
  39. package/esm/state-version-plugin.js.map +1 -0
  40. package/esm/template-plugin.d.ts +3 -0
  41. package/esm/template-plugin.js +10 -0
  42. package/esm/template-plugin.js.map +1 -0
  43. package/esm/terms-index-plugin.d.ts +5 -0
  44. package/esm/terms-index-plugin.js +108 -0
  45. package/esm/terms-index-plugin.js.map +1 -0
  46. package/lib/breadcrumb-plugin.d.ts +3 -0
  47. package/lib/breadcrumb-plugin.js +36 -0
  48. package/lib/constants.d.ts +27 -0
  49. package/lib/constants.js +34 -0
  50. package/lib/images-plugin.d.ts +3 -0
  51. package/lib/images-plugin.js +84 -0
  52. package/lib/index.d.ts +4 -0
  53. package/lib/index.js +17 -0
  54. package/lib/links-plugin.d.ts +3 -0
  55. package/lib/links-plugin.js +89 -0
  56. package/lib/node-utils.d.ts +50 -0
  57. package/lib/node-utils.js +412 -0
  58. package/lib/plugins.d.ts +138 -0
  59. package/lib/plugins.js +153 -0
  60. package/lib/pubdate-plugin.d.ts +9 -0
  61. package/lib/pubdate-plugin.js +143 -0
  62. package/lib/react-plugin.d.ts +3 -0
  63. package/lib/react-plugin.js +130 -0
  64. package/lib/shared.d.ts +36 -0
  65. package/lib/shared.js +169 -0
  66. package/lib/site-data-plugin.d.ts +25 -0
  67. package/lib/site-data-plugin.js +159 -0
  68. package/lib/state-version-plugin.d.ts +3 -0
  69. package/lib/state-version-plugin.js +44 -0
  70. package/lib/template-plugin.d.ts +3 -0
  71. package/lib/template-plugin.js +12 -0
  72. package/lib/terms-index-plugin.d.ts +5 -0
  73. package/lib/terms-index-plugin.js +129 -0
  74. package/package.json +52 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AA0CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BE;AACF,MAAM,UAAU,WAAW,CACzB,KAAe,EACf,eAAmC,EACnC,eAAmC;IAEnC,MAAM,YAAY,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CA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,MAAM;4BACT,GAAG,eAAe;yBACnB,CAAC,CAAA;wBACF,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,eAAe,EAAE,GAAG,YAAY,EAAE,CAAA;wBAC9D,OAAO,cAAc,CAAA;oBACvB,CAAC;oBACD,GAAG,EAAE;wBACH,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;oBACpC,CAAC;iBACF;aACF,CAAA;YACD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,EAAE,CAAA;SAChD;aAAM;YACL,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAA;SACjC;IACH,CAAC,EACD,EAAE,MAAM,EAAE,EAAkB,EAAE,GAAG,EAAE,EAAE,EAAE,CACxC,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,CAAA;AACtB,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { publishRecord, PodliteWebPlugin } from '.';
2
+ export interface PodliteWebPluginParams {
3
+ [name: string]: any;
4
+ }
5
+ export declare function getArticles(item: publishRecord): publishRecord[];
6
+ export declare function getNotes(item: publishRecord): publishRecord[];
7
+ export declare function getPages(item: publishRecord): publishRecord[];
8
+ declare const plugin: () => PodliteWebPlugin;
9
+ export default plugin;
@@ -0,0 +1,137 @@
1
+ import { getFromTree, getTextContentFromNode, makeAttrs, mkRootBlock } from '@podlite/schema';
2
+ import { getPublishAttributes } from './node-utils';
3
+ import { addUrl } from './shared';
4
+ export function getArticles(item) {
5
+ let articles = [];
6
+ const { file } = item;
7
+ const _getArticles = array => {
8
+ // // collect alias
9
+ // const aliases = array.filter(i => i.type == 'alias')
10
+ // at first collect all levels
11
+ const levels = array.filter(node => node.level && node.name === 'head') || [];
12
+ const nodesWithPubdate = levels.filter(node => {
13
+ return makeAttrs(node, {}).exists('pubdate');
14
+ });
15
+ if (nodesWithPubdate.length > 0) {
16
+ for (const nodePublished of nodesWithPubdate) {
17
+ // get next header with same level
18
+ const nextHeader = levels
19
+ .slice(levels.indexOf(nodePublished) + 1) // ignore this and previous nodes
20
+ .filter(node => node.level <= nodePublished.level) // stop then found the same or lower level
21
+ .shift();
22
+ let lastIndexOfArticleNode = !nextHeader ? array.length : array.indexOf(nextHeader);
23
+ const articleContent = array.slice(array.indexOf(nodePublished) + 1, lastIndexOfArticleNode);
24
+ if (articleContent.length) {
25
+ const description = getFromTree(articleContent, 'para')[0];
26
+ const pubdate = makeAttrs(nodePublished, {}).getFirstValue('pubdate');
27
+ //TODO: use footer and header of document for generated articles
28
+ articles.push({
29
+ pubdate,
30
+ title: getTextContentFromNode(nodePublished).trim(),
31
+ type: 'page',
32
+ publishUrl: '',
33
+ sources: [],
34
+ node: mkRootBlock({}, articleContent),
35
+ description,
36
+ file,
37
+ });
38
+ }
39
+ }
40
+ }
41
+ array.forEach(node => {
42
+ if (Array.isArray(node.content)) {
43
+ _getArticles(node.content);
44
+ }
45
+ });
46
+ };
47
+ if (typeof item.node !== 'string') {
48
+ _getArticles(item.node.content);
49
+ }
50
+ return articles;
51
+ }
52
+ export function getNotes(item) {
53
+ const { file } = item;
54
+ const notes = getFromTree(item.node, 'para')
55
+ .filter(n => makeAttrs(n, {}).exists('pubdate'))
56
+ .map((n) => {
57
+ const a_pubdate = makeAttrs(n, {}).getFirstValue('pubdate');
58
+ // Due to cover some cases whan new Date fail on safari, i.e.
59
+ // new Date("2022-05-07 10:00:00").getFullYear() -> NaN
60
+ // convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
61
+ const pubdate = a_pubdate.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
62
+ ? a_pubdate.replace(' ', 'T')
63
+ : a_pubdate;
64
+ //TODO: use footer and header of document for generated notes
65
+ return {
66
+ pubdate,
67
+ type: 'note',
68
+ title: null,
69
+ node: mkRootBlock({}, [n]),
70
+ description: n,
71
+ file,
72
+ publishUrl: '',
73
+ sources: [],
74
+ };
75
+ });
76
+ return notes;
77
+ }
78
+ export function getPages(item) {
79
+ const { file, sources } = item;
80
+ const pages = getFromTree(item.node, 'pod')
81
+ .filter(n => makeAttrs(n, {}).exists('pubdate'))
82
+ .map((n) => {
83
+ const { title, description, puburl, pubdate } = getPublishAttributes(n);
84
+ //TODO: use footer and header of document for generated pages
85
+ return {
86
+ pubdate: pubdate || '',
87
+ type: 'page',
88
+ title,
89
+ node: mkRootBlock({}, [n]),
90
+ description,
91
+ file,
92
+ publishUrl: puburl || '',
93
+ sources,
94
+ };
95
+ });
96
+ return pages;
97
+ }
98
+ const plugin = () => {
99
+ const outCtx = {};
100
+ const onExit = ctx => ({ ...ctx, ...outCtx });
101
+ const onProcess = (recs) => {
102
+ // extract articles and notes from documents
103
+ const rects1 = recs.reduce((acc, item) => {
104
+ const articles = getArticles(item);
105
+ const notes = getNotes(item);
106
+ const pages = getPages(item);
107
+ return [...acc, ...articles, ...notes, ...pages];
108
+ }, []);
109
+ //filter items with pubdate and sort all by pubdate
110
+ //@ts-ignore
111
+ const allItemForPublish = rects1
112
+ .filter(a => a.pubdate)
113
+ .sort((a, b) => {
114
+ //@ts-ignore
115
+ return new Date(a.pubdate) - new Date(b.pubdate);
116
+ });
117
+ // now filter out items for publish in future
118
+ const isDateInFuture = dateString => {
119
+ return new Date().getTime() < new Date(dateString).getTime();
120
+ };
121
+ // save additional info
122
+ const nextPublishTime = (allItemForPublish.filter(a => isDateInFuture(a.pubdate))[0] || {}).pubdate;
123
+ outCtx.nextPublishTime = nextPublishTime;
124
+ // get not "pages" ( not have publishUrl)
125
+ let notPages = allItemForPublish
126
+ .filter(a => !a.publishUrl)
127
+ .filter(a => !!a.pubdate)
128
+ .filter(a => !isDateInFuture(a.pubdate));
129
+ let Pages = allItemForPublish.filter(a => a.publishUrl).filter(a => !(a.pubdate && isDateInFuture(a.pubdate)));
130
+ const notPagesWithPublishAttrs = addUrl(notPages);
131
+ const allRecords = [...notPagesWithPublishAttrs, ...Pages];
132
+ return allRecords;
133
+ };
134
+ return [onProcess, onExit];
135
+ };
136
+ export default plugin;
137
+ //# sourceMappingURL=pubdate-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pubdate-plugin.js","sourceRoot":"","sources":["../src/pubdate-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,SAAS,EAAE,WAAW,EAAW,MAAM,iBAAiB,CAAA;AACtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAMjC,MAAM,UAAU,WAAW,CAAC,IAAmB;IAC7C,IAAI,QAAQ,GAAoB,EAAE,CAAA;IAClC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IACrB,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE;QAC3B,mBAAmB;QACnB,uDAAuD;QACvD,8BAA8B;QAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,CAAA;QAE7E,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5C,OAAO,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;QACF,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;YAC/B,KAAK,MAAM,aAAa,IAAI,gBAAgB,EAAE;gBAC5C,kCAAkC;gBAClC,MAAM,UAAU,GAAG,MAAM;qBACtB,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,iCAAiC;qBAC1E,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,C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U,CAAA;IACnB,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { PodliteWebPlugin } from '.';
2
+ declare const plugin: () => PodliteWebPlugin;
3
+ export default plugin;
@@ -0,0 +1,109 @@
1
+ import { getTextContentFromNode, makeInterator } from '@podlite/schema';
2
+ import { COMPONENTS_LIB } from './constants';
3
+ import * as fs from 'fs';
4
+ import { getPathToOpen } from './node-utils';
5
+ import { makeAstFromSrc } from './shared';
6
+ const plugin = () => {
7
+ const componensMap = new Map();
8
+ const processedNodes = new WeakSet();
9
+ const outCtx = {};
10
+ const onExit = ctx => {
11
+ if (!ctx.testing) {
12
+ // process Components
13
+ let componensFileContent = '';
14
+ for (const key of componensMap.keys()) {
15
+ const componentName = componensMap.get(key);
16
+ componensFileContent += `import ${Array.isArray(componentName) ? `{ ${componentName} }` : componentName} from "${key}"
17
+ export { ${componentName} }
18
+ `;
19
+ }
20
+ componensFileContent += `
21
+ export default {}
22
+ `;
23
+ fs.writeFileSync(COMPONENTS_LIB, componensFileContent, 'utf8');
24
+ }
25
+ return { ...ctx, ...outCtx, ...{ componensMap: Object.fromEntries(componensMap) } };
26
+ };
27
+ const processNode = (node, file) => {
28
+ const rules = {
29
+ // process JSX
30
+ useReact: (node, ctx, interator) => {
31
+ const text = getTextContentFromNode(node);
32
+ const importMatchResult = text.match(/^\s*(?<component>\S+)\s*from\s*['"](?<source>\S+)['"]/);
33
+ if (importMatchResult) {
34
+ //@ts-ignore
35
+ const { component, source } = (importMatchResult || {
36
+ groups: { component: undefined, source: undefined },
37
+ }).groups;
38
+ const { path } = source.match(/^\.?\//) ? getPathToOpen(source, file) : { path: source };
39
+ // save absolute Component path and Component name
40
+ const notDefaultImport = component.match(/{(.*)}/);
41
+ if (notDefaultImport) {
42
+ const components = notDefaultImport[1].split(/\s*,\s*/);
43
+ // check if already exists
44
+ if (componensMap.has(path)) {
45
+ const savedComponents = componensMap.get(path);
46
+ const onlyUnique = (value, index, self) => self.indexOf(value) === index;
47
+ const newComponents = [...savedComponents, ...components].filter(onlyUnique);
48
+ componensMap.set(path, newComponents);
49
+ }
50
+ else {
51
+ componensMap.set(path, components);
52
+ }
53
+ }
54
+ else {
55
+ componensMap.set(path, component);
56
+ }
57
+ }
58
+ else {
59
+ console.warn(`can't parse =React body. Expected =React Component from './somefile.tsx', but got: ${text}`);
60
+ }
61
+ return;
62
+ },
63
+ React: (node, ctx, interator) => {
64
+ const text = getTextContentFromNode(node);
65
+ const doc = makeAstFromSrc(text);
66
+ return { ...node, content: [interator(doc.content, ctx)] };
67
+ },
68
+ };
69
+ return makeInterator(rules)(node, {});
70
+ };
71
+ const onProcess = (recs) => {
72
+ console.log('react-plugin start');
73
+ const res = recs.map(item => {
74
+ const node = processNode(item.node, item.file);
75
+ // process images inside description
76
+ let extra = {};
77
+ if (item.description) {
78
+ extra.description = processNode(item.description, item.file);
79
+ }
80
+ if (item.template && !processedNodes.has(item.template)) {
81
+ const { footer, header } = item.template;
82
+ const processedTemplate = processNode(item.template.node, item.template.file);
83
+ extra.template = item.template;
84
+ extra.template.node = processedTemplate;
85
+ if (footer) {
86
+ extra.template.footer = processNode(footer, item.template.file);
87
+ }
88
+ if (header) {
89
+ extra.template.header = processNode(header, item.template.file);
90
+ }
91
+ processedNodes.add(item.template);
92
+ }
93
+ // process file header and footer
94
+ const { footer, header } = item;
95
+ if (footer) {
96
+ extra.footer = processNode(footer, item.file);
97
+ }
98
+ if (header) {
99
+ extra.header = processNode(header, item.file);
100
+ }
101
+ return { ...item, node, ...extra };
102
+ });
103
+ return res;
104
+ };
105
+ console.log('react-plugin finished');
106
+ return [onProcess, onExit];
107
+ };
108
+ export default plugin;
109
+ //# sourceMappingURL=react-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-plugin.js","sourceRoot":"","sources":["../src/react-plugin.ts"],"names":[],"mappings":"AAA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CAAA"}
@@ -0,0 +1,36 @@
1
+ import { PodNode } from '@podlite/schema';
2
+ import { publishRecord, pubRecord } from '.';
3
+ export declare const getLangFromFilename: (filename?: string) => any;
4
+ export declare const defaultLangForFile: {
5
+ '.rakudoc': string;
6
+ '.pl': string;
7
+ '.pm': string;
8
+ '.rakumod': string;
9
+ };
10
+ export declare const makeAstFromSrc: (src: string) => import("@podlite/schema").RootBlock;
11
+ export declare function isExistsDocBlocks(node: PodNode): boolean;
12
+ export declare function isExistsPubdate(node: PodNode): boolean;
13
+ export declare function getAllArticles(array: any): Omit<pubRecord, "file">[];
14
+ export declare const addUrl: (items: publishRecord[]) => {
15
+ shortUrl: string;
16
+ publishUrl: string;
17
+ sources: string[];
18
+ type: string;
19
+ pubdate: string;
20
+ node: import("@podlite/schema").RootBlock | (string & import("@podlite/schema").RootBlock) | (import("@podlite/schema").BlockNamed & import("@podlite/schema").RootBlock);
21
+ description?: PodNode;
22
+ file: string;
23
+ title: string;
24
+ template?: publishRecord;
25
+ header?: PodNode;
26
+ footer?: PodNode;
27
+ subtitle?: string;
28
+ pluginsData?: {
29
+ [name: string]: any;
30
+ };
31
+ template_file?: string;
32
+ number?: number;
33
+ sxd: string;
34
+ sequence?: number;
35
+ slug?: string;
36
+ }[];
package/esm/shared.js ADDED
@@ -0,0 +1,157 @@
1
+ import { getFromTree, makeAttrs, makeInterator } from '@podlite/schema';
2
+ import { podlite as podlite_core } from 'podlite';
3
+ // now we add base60 letters
4
+ import translit from 'iso_9';
5
+ import base60 from 'newbase60';
6
+ export const getLangFromFilename = (filename) => {
7
+ if (!filename)
8
+ return;
9
+ const ext = filename.split('.').pop();
10
+ return defaultLangForFile[`.${ext}`];
11
+ };
12
+ export const defaultLangForFile = {
13
+ '.rakudoc': 'raku',
14
+ '.pl': 'perl',
15
+ '.pm': 'perl',
16
+ '.rakumod': 'raku',
17
+ };
18
+ export const makeAstFromSrc = (src) => {
19
+ let podlite = podlite_core({ importPlugins: true }).use({});
20
+ let tree = podlite.parse(src);
21
+ const asAst = podlite.toAstResult(tree).interator;
22
+ return asAst;
23
+ };
24
+ export function isExistsDocBlocks(node) {
25
+ let isExistsDocBlocks = false;
26
+ const markAsDocBlock = (node, ctx, interator) => {
27
+ // skip root block
28
+ if (node.type === 'block' && node.name === 'root') {
29
+ if (node.content) {
30
+ return interator(node.content, ctx);
31
+ }
32
+ return;
33
+ }
34
+ isExistsDocBlocks = true;
35
+ };
36
+ const rules = {
37
+ ':para': markAsDocBlock,
38
+ ':block': markAsDocBlock,
39
+ };
40
+ makeInterator(rules)(node, {});
41
+ return isExistsDocBlocks;
42
+ }
43
+ export function isExistsPubdate(node) {
44
+ let isShouldBePublished = false;
45
+ const rules = {
46
+ ':block': (node, ctx, interator) => {
47
+ const config = makeAttrs(node, ctx);
48
+ if (config.exists('pubdate')) {
49
+ isShouldBePublished = true;
50
+ return;
51
+ }
52
+ if (Array.isArray(node.content)) {
53
+ interator(node.content);
54
+ }
55
+ },
56
+ };
57
+ const transformer = makeInterator(rules);
58
+ const res = transformer(node, {});
59
+ return isShouldBePublished;
60
+ }
61
+ export function getAllArticles(array) {
62
+ let articles = [];
63
+ const getArticles = array => {
64
+ // collect alias
65
+ const aliases = array.filter(i => i.type == 'alias');
66
+ // at first collect all levels
67
+ const levels = array.filter(node => node.level && node.name === 'head') || [];
68
+ const nodesWithPubdate = levels.filter(node => {
69
+ return makeAttrs(node, {}).exists('pubdate');
70
+ });
71
+ if (nodesWithPubdate.length > 0) {
72
+ const nodePublished = nodesWithPubdate[0];
73
+ // get next header with same level
74
+ const nextHeader = levels
75
+ .slice(levels.indexOf(nodePublished) + 1) // ignore this and previous nodes
76
+ .filter(node => node.level <= nodePublished.level) // stop then found the same or lower level
77
+ .shift();
78
+ let lastIndexOfArticleNode = !nextHeader ? array.length : array.indexOf(nextHeader);
79
+ const articleContent = array.slice(array.indexOf(nodePublished) + 1, lastIndexOfArticleNode);
80
+ if (articleContent.length) {
81
+ const description = getFromTree(articleContent, 'para')[0];
82
+ const pubdate = makeAttrs(nodePublished, {}).getFirstValue('pubdate');
83
+ articles.push({
84
+ pubdate,
85
+ type: 'page',
86
+ node: articleContent,
87
+ description,
88
+ });
89
+ }
90
+ }
91
+ array.forEach(node => {
92
+ if (Array.isArray(node.content)) {
93
+ getArticles(node.content);
94
+ }
95
+ });
96
+ };
97
+ getArticles(array);
98
+ return articles;
99
+ }
100
+ export const addUrl = (items) => {
101
+ const withSxd = items.map(i => {
102
+ const { file: f } = i;
103
+ const attrs = i;
104
+ const pubDate = new Date(i.pubdate);
105
+ const sxd = base60.DateToSxg(pubDate);
106
+ const type = i.type === 'note' ? 'n' : 'a';
107
+ // make short name from title
108
+ let words = (attrs.title || '').split(/\s/);
109
+ let res = [];
110
+ while ([...res, words[0]].join(' ').length < 120) {
111
+ //@ts-ignore
112
+ res.push(words.shift());
113
+ }
114
+ let shortTitle = res.join(' ');
115
+ // translit only cyrillic
116
+ const translit2 = /[а-яА-ЯЁё]/.test(shortTitle) ? translit(shortTitle, 5) : shortTitle;
117
+ // make url clean
118
+ const slug = ((translit2.replace(/`/, '') || '').replace(/\W+/g, '-') || '')
119
+ .replace(/(^[-]+|[-]+$)/g, '')
120
+ .toLowerCase();
121
+ return { ...attrs, type, sxd, slug, file: f };
122
+ });
123
+ // get count of each type on corresponding date
124
+ withSxd.reduce((acc, item) => {
125
+ const { sxd, type } = item;
126
+ acc[sxd] = acc[sxd] || {};
127
+ acc[sxd][type] = acc[sxd][type] || 0;
128
+ acc[sxd][type]++;
129
+ item.number = acc[sxd][type];
130
+ return acc;
131
+ }, {});
132
+ // sequence - index of record at all in that day
133
+ withSxd.reduce((acc, item) => {
134
+ const { sxd } = item;
135
+ acc[sxd] = acc[sxd] || 0;
136
+ acc[sxd]++;
137
+ item.sequence = acc[sxd];
138
+ return acc;
139
+ }, {});
140
+ return withSxd.map(item => {
141
+ const { type, number, sxd, slug, pubdate, sequence } = item;
142
+ const shortUrl = `/${type}${sxd}${number}`;
143
+ // /2019/12/34/a1/WriteAt-my-opensource-startup-on-Perl-6-Pod
144
+ const date = new Date(pubdate);
145
+ const month = date.getMonth() + 1;
146
+ const year = date.getFullYear();
147
+ const day = date.getDate();
148
+ // !!!!! publishUrl may exists
149
+ const publishUrl = `/${year}/${month}/${day}/${sequence}/${slug}`.replace(/\/$/, '');
150
+ const sources = [
151
+ shortUrl,
152
+ // `/${year}/${month}/${day}/${sequence}`,
153
+ ];
154
+ return { ...item, shortUrl, publishUrl, sources };
155
+ });
156
+ };
157
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAA;AAEjG,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA;AACjD,4BAA4B;AAE5B,OAAO,QAAQ,MAAM,OAAO,CAAA;AAC5B,OAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAAiB,EAAE,EAAE;IACvD,IAAI,CAAC,QAAQ;QAAE,OAAM;IACrB,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAA;IACrC,OAAO,kBAAkB,CAAC,IAAI,GAAG,EAAE,CAAC,CAAA;AACtC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,UAAU,EAAE,MAAM;IAClB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,MAAM;IACb,UAAU,EAAE,MAAM;CACnB,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,IAAI,OAAO,GAAG,YAAY,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC3D,I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C9B,MAAM,UAAU,GAAG,IAAI,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QACpF,MAAM,OAAO,GAAG;YACd,QAAQ;YACR,0CAA0C;SAC3C,CAAA;QACD,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAA;IACnD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { PodliteWebPlugin, publishRecord } from '.';
2
+ export interface SiteInfo {
3
+ redirects: {
4
+ source: string;
5
+ destination: string;
6
+ statusCode: number;
7
+ }[];
8
+ postsPerPage: number;
9
+ favicon: string;
10
+ url: string;
11
+ node: any;
12
+ title: string;
13
+ globalStyles: string;
14
+ footer: string;
15
+ gtmId: string;
16
+ item: publishRecord;
17
+ }
18
+ interface siteDataPluginInitParams {
19
+ public_path: string;
20
+ indexFilePath: string;
21
+ built_path: string;
22
+ site_url?: string;
23
+ }
24
+ declare const plugin: ({ public_path, indexFilePath, built_path, site_url, }: siteDataPluginInitParams) => PodliteWebPlugin;
25
+ export default plugin;
@@ -0,0 +1,135 @@
1
+ import { getFromTree, getTextContentFromNode, makeAttrs, makeInterator } from '@podlite/schema';
2
+ import { BUILT_PATH, INDEX_PATH, POSTS_PATH, PUBLIC_PATH } from './constants';
3
+ import * as fs from 'fs';
4
+ import { streamWriteArray } from '.';
5
+ import pathFs from 'path';
6
+ const plugin = ({ public_path = PUBLIC_PATH, indexFilePath = `${POSTS_PATH}/${INDEX_PATH}`, built_path = BUILT_PATH, site_url, }) => {
7
+ let indexPage;
8
+ let redirects = [];
9
+ let allRecords = [];
10
+ const outCtx = {};
11
+ const onExit = ctx => {
12
+ let title;
13
+ let subtitle;
14
+ let author;
15
+ let footer = '';
16
+ // collect site metadata like TITLE, SUBTITLE and attributes from pod
17
+ const [pod] = getFromTree(indexPage.node, 'pod');
18
+ const attr = makeAttrs(pod, {});
19
+ const pageAttr = Object.fromEntries(Object.keys(attr.asHash()).map(k => [k, attr.getFirstValue(k)]));
20
+ const { postsPerPage, favicon, puburl, url, globalStyles, gtmId } = pageAttr;
21
+ // process favicon file
22
+ const faviconPath = favicon ? pathFs.join(pathFs.dirname(indexFilePath), favicon) : 'src/favicon.png';
23
+ const { base, ext } = pathFs.parse(faviconPath);
24
+ const faviconFileName = `favicon${ext}`;
25
+ if (!ctx.testing) {
26
+ fs.copyFileSync(faviconPath, `${public_path}/${faviconFileName}`);
27
+ }
28
+ //clean up index page and collect needed data
29
+ const pageNode = makeInterator({
30
+ TITLE: (node, ctx, interator) => {
31
+ title = getTextContentFromNode(node);
32
+ },
33
+ SUBTITLE: (node, ctx, interator) => {
34
+ subtitle = getTextContentFromNode(node);
35
+ },
36
+ AUTHOR: (node, ctx, interator) => {
37
+ const attr = makeAttrs(node, ctx);
38
+ author = Object.fromEntries(Object.keys(attr.asHash()).map(k => [k, attr.getFirstValue(k)]));
39
+ },
40
+ FOOTER: (node, ctx, interator) => {
41
+ footer = node.content;
42
+ },
43
+ })(indexPage.node, {});
44
+ const siteData = {
45
+ postsPerPage,
46
+ favicon: faviconFileName,
47
+ url: site_url || process.env.SITE_URL || url || puburl,
48
+ node: pageNode,
49
+ title,
50
+ globalStyles,
51
+ redirects,
52
+ footer,
53
+ gtmId,
54
+ item: { ...indexPage, node: pageNode },
55
+ };
56
+ // !!! now get previsuly prepared data from context and prepare control.json
57
+ const { stateVersion, nextPublishTime, imagesMap } = ctx;
58
+ const controlJson = {
59
+ stateVersion,
60
+ nextPublishTime,
61
+ };
62
+ if (!ctx.testing) {
63
+ // save control.json
64
+ fs.writeFileSync(`${public_path}/control.json`, JSON.stringify(controlJson, null, 2));
65
+ }
66
+ const dataJson = {
67
+ all: [],
68
+ control: controlJson,
69
+ imagesMap: imagesMap?.size ? Object.fromEntries(imagesMap) : {},
70
+ siteInfo: siteData,
71
+ };
72
+ if (!ctx.testing) {
73
+ streamWriteArray(allRecords, `${built_path}/pages.json`)
74
+ .then(() => console.log('All pages written successfully'))
75
+ .catch(err => console.error('Error writing file:', err));
76
+ fs.writeFileSync(`${built_path}/data.json`, JSON.stringify(dataJson));
77
+ fs.writeFileSync(`${built_path}/siteInfo.json`, JSON.stringify(siteData, null, 2));
78
+ fs.writeFileSync(`${built_path}/imagesMap.json`, JSON.stringify(imagesMap, null, 2));
79
+ }
80
+ // prepare data for LastArticles component
81
+ if (!ctx.testing) {
82
+ const source = () => allRecords.filter(i => i.publishUrl).filter(({ type = '' }) => type !== 'page');
83
+ const articles = source().reverse().slice(0, 10);
84
+ // if (!articles[articles.length - 1]) {
85
+ // throw new Error('No articles found' + JSON.stringify({'articles.length - 1':articles.length - 1, articles, 'allRecords':allRecords.length}, null, 2))
86
+ // }
87
+ // const lastArticleUrl = articles[articles.length - 1].publishUrl
88
+ // const articleIndex = source().findIndex(({ publishUrl }) => publishUrl === lastArticleUrl)
89
+ // const prev = source()[articleIndex - 1]
90
+ fs.writeFileSync(`${built_path}/lastArticles.json`, JSON.stringify({ articles, prev: {} }, null, 2));
91
+ }
92
+ // process GlobalStyles
93
+ let stylesContent = '';
94
+ if (siteData.globalStyles) {
95
+ const pathFs = require('path');
96
+ const docDirPath = pathFs.dirname(`${built_path}/styles.css`);
97
+ const path = pathFs.relative(docDirPath, pathFs.join(pathFs.dirname(indexFilePath), siteData.globalStyles));
98
+ stylesContent += `
99
+ @import '${path}';
100
+ `;
101
+ }
102
+ else {
103
+ const path = '@Styles/default';
104
+ stylesContent += `
105
+ @import '${path}';
106
+ `;
107
+ }
108
+ if (!ctx.testing) {
109
+ // /built/styles.css
110
+ fs.writeFileSync(`${built_path}/styles.css`, stylesContent, 'utf8');
111
+ }
112
+ return { ...ctx, ...outCtx, siteData };
113
+ };
114
+ const onProcess = (recs) => {
115
+ // collect redirects
116
+ recs.map(item => {
117
+ const { publishUrl, sources } = item;
118
+ sources.forEach(src => {
119
+ redirects.push({ source: src, destination: publishUrl, statusCode: 308 }); //permanent redirect
120
+ });
121
+ });
122
+ // get index page or throw error
123
+ indexPage = recs.find(item => item.file === indexFilePath);
124
+ if (!indexPage) {
125
+ console.log(JSON.stringify(recs.map(i => i.file), null, 2));
126
+ throw new Error('Index page not found. Used path: ' + indexFilePath);
127
+ }
128
+ indexPage.publishUrl = '/';
129
+ allRecords.push(...recs);
130
+ return recs;
131
+ };
132
+ return [onProcess, onExit];
133
+ };
134
+ export default plugin;
135
+ //# sourceMappingURL=site-data-plugin.js.map