@podlite/publisher 0.0.23 → 0.0.25
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.podlite +6 -0
- package/esm/site-data-plugin.d.ts +2 -0
- package/esm/site-data-plugin.js +17 -17
- package/esm/site-data-plugin.js.map +1 -1
- package/esm/state-version-plugin.d.ts +1 -1
- package/esm/state-version-plugin.js +2 -2
- package/esm/state-version-plugin.js.map +1 -1
- package/lib/site-data-plugin.d.ts +2 -0
- package/lib/site-data-plugin.js +19 -17
- package/lib/state-version-plugin.d.ts +1 -1
- package/lib/state-version-plugin.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.podlite
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
=head1 Upcoming
|
|
4
4
|
|
|
5
|
+
=head1 0.0.25
|
|
6
|
+
|
|
7
|
+
=item C<stateVersionPlugin> accepts optional C<appVersion> parameter; appended to C<stateVersion> as C<+app<v>>
|
|
8
|
+
|
|
9
|
+
=item C<site-data-plugin> reads C<:theme> from root pod and emits C<@import '@Styles/themes/<name>.css'>; layered before C<:globalStyles> override
|
|
10
|
+
|
|
5
11
|
=head1 0.0.20
|
|
6
12
|
|
|
7
13
|
=item extend Selector parsing: C<file:> scheme with suffix-match against C<publishRecord.file>, and pipe-separated block-name filters (e.g. C<file:terms.podlite | defn, para>). C<include-resolve-plugin> now inlines every matched block at the C<=include> location, not just the first
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PodliteWebPlugin, publishRecord } from '.';
|
|
2
|
+
export declare function buildStylesContent(theme: string | undefined, globalStylesPath: string | undefined): string;
|
|
2
3
|
export interface SiteInfo {
|
|
3
4
|
redirects: {
|
|
4
5
|
source: string;
|
|
@@ -11,6 +12,7 @@ export interface SiteInfo {
|
|
|
11
12
|
node: any;
|
|
12
13
|
title: string;
|
|
13
14
|
globalStyles: string;
|
|
15
|
+
theme?: string;
|
|
14
16
|
footer: string;
|
|
15
17
|
gtmId: string;
|
|
16
18
|
item: publishRecord;
|
package/esm/site-data-plugin.js
CHANGED
|
@@ -3,6 +3,16 @@ import { BUILT_PATH, INDEX_PATH, POSTS_PATH, PUBLIC_PATH } from './constants';
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import { processFile } from '.';
|
|
5
5
|
import pathFs from 'path';
|
|
6
|
+
export function buildStylesContent(theme, globalStylesPath) {
|
|
7
|
+
const imports = [];
|
|
8
|
+
if (theme)
|
|
9
|
+
imports.push(`@import '@Styles/themes/${theme}.css';`);
|
|
10
|
+
if (globalStylesPath)
|
|
11
|
+
imports.push(`@import '${globalStylesPath}';`);
|
|
12
|
+
if (!theme && !globalStylesPath)
|
|
13
|
+
imports.push(`@import '@Styles/default';`);
|
|
14
|
+
return imports.map(i => `\n ${i}\n `).join('');
|
|
15
|
+
}
|
|
6
16
|
const plugin = ({ public_path = PUBLIC_PATH, indexFilePath = `${POSTS_PATH}/${INDEX_PATH}`, built_path = BUILT_PATH, site_url, }) => {
|
|
7
17
|
let indexPage;
|
|
8
18
|
let redirects = [];
|
|
@@ -17,7 +27,7 @@ const plugin = ({ public_path = PUBLIC_PATH, indexFilePath = `${POSTS_PATH}/${IN
|
|
|
17
27
|
const [pod] = getFromTree(indexPage.node, 'pod');
|
|
18
28
|
const attr = makeAttrs(pod, {});
|
|
19
29
|
const pageAttr = Object.fromEntries(Object.keys(attr.asHash()).map(k => [k, attr.getFirstValue(k)]));
|
|
20
|
-
const { postsPerPage, favicon, puburl, url, globalStyles, gtmId, templateFile } = pageAttr;
|
|
30
|
+
const { postsPerPage, favicon, puburl, url, globalStyles, theme, gtmId, templateFile } = pageAttr;
|
|
21
31
|
// process favicon file
|
|
22
32
|
const faviconPath = favicon ? pathFs.join(pathFs.dirname(indexFilePath), favicon) : 'src/favicon.png';
|
|
23
33
|
const { base, ext } = pathFs.parse(faviconPath);
|
|
@@ -48,6 +58,7 @@ const plugin = ({ public_path = PUBLIC_PATH, indexFilePath = `${POSTS_PATH}/${IN
|
|
|
48
58
|
node: pageNode,
|
|
49
59
|
title,
|
|
50
60
|
globalStyles,
|
|
61
|
+
...(theme && { theme }),
|
|
51
62
|
redirects,
|
|
52
63
|
footer,
|
|
53
64
|
gtmId,
|
|
@@ -75,22 +86,11 @@ const plugin = ({ public_path = PUBLIC_PATH, indexFilePath = `${POSTS_PATH}/${IN
|
|
|
75
86
|
fs.writeFileSync(`${built_path}/siteInfo.json`, JSON.stringify(siteData, null, 2));
|
|
76
87
|
fs.writeFileSync(`${built_path}/imagesMap.json`, JSON.stringify(imagesMap, null, 2));
|
|
77
88
|
}
|
|
78
|
-
// process
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const path = pathFs.relative(docDirPath, pathFs.join(pathFs.dirname(indexFilePath), siteData.globalStyles));
|
|
84
|
-
stylesContent += `
|
|
85
|
-
@import '${path}';
|
|
86
|
-
`;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
const path = '@Styles/default';
|
|
90
|
-
stylesContent += `
|
|
91
|
-
@import '${path}';
|
|
92
|
-
`;
|
|
93
|
-
}
|
|
89
|
+
// process styles: theme layer + globalStyles layer + default fallback
|
|
90
|
+
const globalStylesPath = siteData.globalStyles
|
|
91
|
+
? pathFs.relative(pathFs.dirname(`${built_path}/styles.css`), pathFs.join(pathFs.dirname(indexFilePath), siteData.globalStyles))
|
|
92
|
+
: undefined;
|
|
93
|
+
const stylesContent = buildStylesContent(siteData.theme, globalStylesPath);
|
|
94
94
|
if (!ctx.testing) {
|
|
95
95
|
// /built/styles.css
|
|
96
96
|
fs.writeFileSync(`${built_path}/styles.css`, stylesContent, 'utf8');
|
|
@@ -1 +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,E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AAa,CAAC,CAAA;SACrE;QACD,SAAS,CAAC,UAAU,GAAG,GAAG,CAAA;QAE1B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,EAAO,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAA;QAEnH,MAAM,SAAS,GAAG;;;;;EAKpB,YAAY;;;CAGb,CAAA;QACG,MAAM,QAAQ,GAAG,WAAW,CAAC,kCAAkC,EAAE,SAAS,CAAC,CAAA;QAC3E,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAA;QAClC,OAAO,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC5B,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as CRC32 from 'crc-32';
|
|
2
2
|
import { getTextContentFromNode } from '@podlite/schema';
|
|
3
3
|
const version = require('../package.json').version;
|
|
4
|
-
const plugin = () => {
|
|
4
|
+
const plugin = (appVersion) => {
|
|
5
5
|
const outCtx = {};
|
|
6
6
|
let crc_sum = '';
|
|
7
7
|
const onExit = ctx => {
|
|
8
|
-
outCtx.stateVersion = CRC32.str(crc_sum) + '+v' + version;
|
|
8
|
+
outCtx.stateVersion = CRC32.str(crc_sum) + '+v' + version + (appVersion ? '+app' + appVersion : '');
|
|
9
9
|
return { ...ctx, ...outCtx };
|
|
10
10
|
};
|
|
11
11
|
const getStateVersion = (allREcords) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-version-plugin.js","sourceRoot":"","sources":["../src/state-version-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PodliteWebPlugin, publishRecord } from '.';
|
|
2
|
+
export declare function buildStylesContent(theme: string | undefined, globalStylesPath: string | undefined): string;
|
|
2
3
|
export interface SiteInfo {
|
|
3
4
|
redirects: {
|
|
4
5
|
source: string;
|
|
@@ -11,6 +12,7 @@ export interface SiteInfo {
|
|
|
11
12
|
node: any;
|
|
12
13
|
title: string;
|
|
13
14
|
globalStyles: string;
|
|
15
|
+
theme?: string;
|
|
14
16
|
footer: string;
|
|
15
17
|
gtmId: string;
|
|
16
18
|
item: publishRecord;
|
package/lib/site-data-plugin.js
CHANGED
|
@@ -22,11 +22,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.buildStylesContent = void 0;
|
|
25
26
|
const schema_1 = require("@podlite/schema");
|
|
26
27
|
const constants_1 = require("./constants");
|
|
27
28
|
const fs = __importStar(require("fs"));
|
|
28
29
|
const _1 = require(".");
|
|
29
30
|
const path_1 = __importDefault(require("path"));
|
|
31
|
+
function buildStylesContent(theme, globalStylesPath) {
|
|
32
|
+
const imports = [];
|
|
33
|
+
if (theme)
|
|
34
|
+
imports.push(`@import '@Styles/themes/${theme}.css';`);
|
|
35
|
+
if (globalStylesPath)
|
|
36
|
+
imports.push(`@import '${globalStylesPath}';`);
|
|
37
|
+
if (!theme && !globalStylesPath)
|
|
38
|
+
imports.push(`@import '@Styles/default';`);
|
|
39
|
+
return imports.map(i => `\n ${i}\n `).join('');
|
|
40
|
+
}
|
|
41
|
+
exports.buildStylesContent = buildStylesContent;
|
|
30
42
|
const plugin = ({ public_path = constants_1.PUBLIC_PATH, indexFilePath = `${constants_1.POSTS_PATH}/${constants_1.INDEX_PATH}`, built_path = constants_1.BUILT_PATH, site_url, }) => {
|
|
31
43
|
let indexPage;
|
|
32
44
|
let redirects = [];
|
|
@@ -41,7 +53,7 @@ const plugin = ({ public_path = constants_1.PUBLIC_PATH, indexFilePath = `${cons
|
|
|
41
53
|
const [pod] = (0, schema_1.getFromTree)(indexPage.node, 'pod');
|
|
42
54
|
const attr = (0, schema_1.makeAttrs)(pod, {});
|
|
43
55
|
const pageAttr = Object.fromEntries(Object.keys(attr.asHash()).map(k => [k, attr.getFirstValue(k)]));
|
|
44
|
-
const { postsPerPage, favicon, puburl, url, globalStyles, gtmId, templateFile } = pageAttr;
|
|
56
|
+
const { postsPerPage, favicon, puburl, url, globalStyles, theme, gtmId, templateFile } = pageAttr;
|
|
45
57
|
// process favicon file
|
|
46
58
|
const faviconPath = favicon ? path_1.default.join(path_1.default.dirname(indexFilePath), favicon) : 'src/favicon.png';
|
|
47
59
|
const { base, ext } = path_1.default.parse(faviconPath);
|
|
@@ -72,6 +84,7 @@ const plugin = ({ public_path = constants_1.PUBLIC_PATH, indexFilePath = `${cons
|
|
|
72
84
|
node: pageNode,
|
|
73
85
|
title,
|
|
74
86
|
globalStyles,
|
|
87
|
+
...(theme && { theme }),
|
|
75
88
|
redirects,
|
|
76
89
|
footer,
|
|
77
90
|
gtmId,
|
|
@@ -99,22 +112,11 @@ const plugin = ({ public_path = constants_1.PUBLIC_PATH, indexFilePath = `${cons
|
|
|
99
112
|
fs.writeFileSync(`${built_path}/siteInfo.json`, JSON.stringify(siteData, null, 2));
|
|
100
113
|
fs.writeFileSync(`${built_path}/imagesMap.json`, JSON.stringify(imagesMap, null, 2));
|
|
101
114
|
}
|
|
102
|
-
// process
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const path = pathFs.relative(docDirPath, pathFs.join(pathFs.dirname(indexFilePath), siteData.globalStyles));
|
|
108
|
-
stylesContent += `
|
|
109
|
-
@import '${path}';
|
|
110
|
-
`;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
const path = '@Styles/default';
|
|
114
|
-
stylesContent += `
|
|
115
|
-
@import '${path}';
|
|
116
|
-
`;
|
|
117
|
-
}
|
|
115
|
+
// process styles: theme layer + globalStyles layer + default fallback
|
|
116
|
+
const globalStylesPath = siteData.globalStyles
|
|
117
|
+
? path_1.default.relative(path_1.default.dirname(`${built_path}/styles.css`), path_1.default.join(path_1.default.dirname(indexFilePath), siteData.globalStyles))
|
|
118
|
+
: undefined;
|
|
119
|
+
const stylesContent = buildStylesContent(siteData.theme, globalStylesPath);
|
|
118
120
|
if (!ctx.testing) {
|
|
119
121
|
// /built/styles.css
|
|
120
122
|
fs.writeFileSync(`${built_path}/styles.css`, stylesContent, 'utf8');
|
|
@@ -22,11 +22,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
const CRC32 = __importStar(require("crc-32"));
|
|
23
23
|
const schema_1 = require("@podlite/schema");
|
|
24
24
|
const version = require('../package.json').version;
|
|
25
|
-
const plugin = () => {
|
|
25
|
+
const plugin = (appVersion) => {
|
|
26
26
|
const outCtx = {};
|
|
27
27
|
let crc_sum = '';
|
|
28
28
|
const onExit = ctx => {
|
|
29
|
-
outCtx.stateVersion = CRC32.str(crc_sum) + '+v' + version;
|
|
29
|
+
outCtx.stateVersion = CRC32.str(crc_sum) + '+v' + version + (appVersion ? '+app' + appVersion : '');
|
|
30
30
|
return { ...ctx, ...outCtx };
|
|
31
31
|
};
|
|
32
32
|
const getStateVersion = (allREcords) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podlite/publisher",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "Publishing toolkit for Podlite — transform documents to HTML, generate sites",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"homepage": "https://podlite.org",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"transform"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@podlite/schema": "0.0.
|
|
56
|
+
"@podlite/schema": "0.0.44",
|
|
57
57
|
"crc-32": "^1.2.2",
|
|
58
58
|
"gray-matter": "^4.0.3",
|
|
59
59
|
"iso_9": "^1.0.4",
|