jsonresume-theme-data-driven 0.2.1 → 0.2.3
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 +15 -0
- package/dist/index.js +67 -25
- package/package.json +2 -2
- package/src/index.jsx +6 -25
- package/tests/theme.test.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# jsonresume-theme-data-driven
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d68a1b3: use @jsonresume/core/ssr renderResumeDocument
|
|
8
|
+
- Updated dependencies [ff09f75]
|
|
9
|
+
- @jsonresume/core@0.3.1
|
|
10
|
+
|
|
11
|
+
## 0.2.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [ff0f85b]
|
|
16
|
+
- @jsonresume/core@0.3.0
|
|
17
|
+
|
|
3
18
|
## 0.2.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
3
|
import o, { useRef, useContext, useState, useMemo, useEffect, useDebugValue, createElement, createContext } from "react";
|
|
4
4
|
var __assign = function() {
|
|
5
5
|
__assign = Object.assign || function __assign2(t) {
|
|
@@ -1300,6 +1300,65 @@ var vt = /^\s*<\/[a-z]/i, gt = (function() {
|
|
|
1300
1300
|
"production" !== process.env.NODE_ENV && "undefined" != typeof navigator && "ReactNative" === navigator.product && console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");
|
|
1301
1301
|
var wt = "__sc-".concat(f, "__");
|
|
1302
1302
|
"production" !== process.env.NODE_ENV && "test" !== process.env.NODE_ENV && "undefined" != typeof window && (window[wt] || (window[wt] = 0), 1 === window[wt] && console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."), window[wt] += 1);
|
|
1303
|
+
const CSS_RESET = "<style>*,*::before,*::after{box-sizing:border-box}html,body{margin:0;padding:0}body{-webkit-font-smoothing:antialiased}</style>";
|
|
1304
|
+
const TOKENS_CSS_HREF = "https://unpkg.com/@jsonresume/core/dist/tokens.css";
|
|
1305
|
+
const FONTS_PRECONNECT = '<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>';
|
|
1306
|
+
function isHref(value) {
|
|
1307
|
+
return /^(https?:)?\/\//.test(value) || value.trim().startsWith("<link");
|
|
1308
|
+
}
|
|
1309
|
+
function familyParam(family) {
|
|
1310
|
+
const [name, ...rest] = String(family).split(":");
|
|
1311
|
+
const encodedName = name.trim().replace(/\s+/g, "+");
|
|
1312
|
+
return rest.length ? `${encodedName}:${rest.join(":")}` : encodedName;
|
|
1313
|
+
}
|
|
1314
|
+
function googleFontsLinks(families) {
|
|
1315
|
+
if (!Array.isArray(families) || families.length === 0) return "";
|
|
1316
|
+
const passthrough = [];
|
|
1317
|
+
const names = [];
|
|
1318
|
+
for (const entry of families) {
|
|
1319
|
+
if (entry == null || entry === "") continue;
|
|
1320
|
+
if (isHref(entry)) passthrough.push(entry);
|
|
1321
|
+
else names.push(entry);
|
|
1322
|
+
}
|
|
1323
|
+
const links = passthrough.map(
|
|
1324
|
+
(href) => href.trim().startsWith("<link") ? href : `<link href="${href}" rel="stylesheet">`
|
|
1325
|
+
);
|
|
1326
|
+
if (names.length > 0) {
|
|
1327
|
+
const query = names.map(familyParam).join("&family=");
|
|
1328
|
+
links.unshift(
|
|
1329
|
+
`<link href="https://fonts.googleapis.com/css2?family=${query}&display=swap" rel="stylesheet">`
|
|
1330
|
+
);
|
|
1331
|
+
}
|
|
1332
|
+
if (links.length === 0) return "";
|
|
1333
|
+
return FONTS_PRECONNECT + links.join("");
|
|
1334
|
+
}
|
|
1335
|
+
function renderResumeDocument(element, options = {}) {
|
|
1336
|
+
const {
|
|
1337
|
+
fonts,
|
|
1338
|
+
title,
|
|
1339
|
+
lang = "en",
|
|
1340
|
+
dir = "ltr",
|
|
1341
|
+
reset = false,
|
|
1342
|
+
head = "",
|
|
1343
|
+
includeTokensCss = true,
|
|
1344
|
+
bodyClass
|
|
1345
|
+
} = options;
|
|
1346
|
+
const sheet = new gt();
|
|
1347
|
+
let html;
|
|
1348
|
+
let styleTags;
|
|
1349
|
+
try {
|
|
1350
|
+
html = renderToStaticMarkup(sheet.collectStyles(element));
|
|
1351
|
+
styleTags = sheet.getStyleTags();
|
|
1352
|
+
} finally {
|
|
1353
|
+
sheet.seal();
|
|
1354
|
+
}
|
|
1355
|
+
const fontLinks = googleFontsLinks(fonts);
|
|
1356
|
+
const tokensLink = includeTokensCss ? `<link rel="stylesheet" href="${TOKENS_CSS_HREF}">` : "";
|
|
1357
|
+
const resetTag = reset ? CSS_RESET : "";
|
|
1358
|
+
const titleTag = title ? `<title>${title}</title>` : "";
|
|
1359
|
+
const bodyAttr = bodyClass ? ` class="${bodyClass}"` : "";
|
|
1360
|
+
return `<!DOCTYPE html><html lang="${lang}" dir="${dir}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">` + fontLinks + tokensLink + resetTag + head + styleTags + titleTag + `</head><body${bodyAttr}>${html}</body></html>`;
|
|
1361
|
+
}
|
|
1303
1362
|
createContext({
|
|
1304
1363
|
theme: "professional",
|
|
1305
1364
|
setTheme: () => {
|
|
@@ -1446,7 +1505,9 @@ function formatDateRange({
|
|
|
1446
1505
|
return formatter.format(date);
|
|
1447
1506
|
};
|
|
1448
1507
|
const start = formatDate(startDate);
|
|
1449
|
-
if (endDate === void 0)
|
|
1508
|
+
if (endDate === void 0) {
|
|
1509
|
+
return start;
|
|
1510
|
+
}
|
|
1450
1511
|
const end = formatDate(endDate);
|
|
1451
1512
|
return `${start} - ${end}`;
|
|
1452
1513
|
}
|
|
@@ -6313,29 +6374,10 @@ function Resume({ resume }) {
|
|
|
6313
6374
|
] })
|
|
6314
6375
|
] });
|
|
6315
6376
|
}
|
|
6316
|
-
const render = (resume) => {
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
sheet.collectStyles(/* @__PURE__ */ jsx(Resume, { resume }))
|
|
6321
|
-
);
|
|
6322
|
-
const styles = sheet.getStyleTags();
|
|
6323
|
-
return `<!DOCTYPE html>
|
|
6324
|
-
<html lang="en">
|
|
6325
|
-
<head>
|
|
6326
|
-
<meta charset="UTF-8">
|
|
6327
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6328
|
-
<title>${resume.basics?.name || "Resume"}</title>
|
|
6329
|
-
${styles}
|
|
6330
|
-
</head>
|
|
6331
|
-
<body>
|
|
6332
|
-
${html}
|
|
6333
|
-
</body>
|
|
6334
|
-
</html>`;
|
|
6335
|
-
} finally {
|
|
6336
|
-
sheet.seal();
|
|
6337
|
-
}
|
|
6338
|
-
};
|
|
6377
|
+
const render = (resume) => renderResumeDocument(/* @__PURE__ */ jsx(Resume, { resume }), {
|
|
6378
|
+
title: resume.basics?.name || "Resume",
|
|
6379
|
+
includeTokensCss: false
|
|
6380
|
+
});
|
|
6339
6381
|
const index = { render };
|
|
6340
6382
|
export {
|
|
6341
6383
|
Resume,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsonresume-theme-data-driven",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Data-driven analytical theme with sky blue accent - built with @resume/core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"react": "^19.2.0",
|
|
29
29
|
"react-dom": "^19.2.0",
|
|
30
30
|
"styled-components": "^6.1.19",
|
|
31
|
-
"@jsonresume/core": "0.
|
|
31
|
+
"@jsonresume/core": "0.3.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@vitejs/plugin-react": "^4.3.4",
|
package/src/index.jsx
CHANGED
|
@@ -4,33 +4,14 @@
|
|
|
4
4
|
* Built with @jsonresume/core primitives and React SSR
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { ServerStyleSheet } from 'styled-components';
|
|
7
|
+
import { renderResumeDocument } from '@jsonresume/core/ssr';
|
|
9
8
|
import Resume from './ui/Resume.jsx';
|
|
10
9
|
|
|
11
|
-
export const render = (resume) =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
const styles = sheet.getStyleTags();
|
|
18
|
-
return `<!DOCTYPE html>
|
|
19
|
-
<html lang="en">
|
|
20
|
-
<head>
|
|
21
|
-
<meta charset="UTF-8">
|
|
22
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
23
|
-
<title>${resume.basics?.name || 'Resume'}</title>
|
|
24
|
-
${styles}
|
|
25
|
-
</head>
|
|
26
|
-
<body>
|
|
27
|
-
${html}
|
|
28
|
-
</body>
|
|
29
|
-
</html>`;
|
|
30
|
-
} finally {
|
|
31
|
-
sheet.seal();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
10
|
+
export const render = (resume) =>
|
|
11
|
+
renderResumeDocument(<Resume resume={resume} />, {
|
|
12
|
+
title: resume.basics?.name || 'Resume',
|
|
13
|
+
includeTokensCss: false,
|
|
14
|
+
});
|
|
34
15
|
|
|
35
16
|
export { Resume };
|
|
36
17
|
export default { render };
|
package/tests/theme.test.js
CHANGED
|
@@ -73,7 +73,7 @@ describe('Data-Driven Theme', () => {
|
|
|
73
73
|
const html = render(completeResume);
|
|
74
74
|
|
|
75
75
|
expect(html).toContain('<!DOCTYPE html>');
|
|
76
|
-
expect(html).toContain('<html lang="en">');
|
|
76
|
+
expect(html).toContain('<html lang="en" dir="ltr">');
|
|
77
77
|
expect(html).toContain('</html>');
|
|
78
78
|
});
|
|
79
79
|
|