jsonresume-theme-wintermuted 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 James Onnyeholt
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.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # jsonresume-theme-wintermuted
2
+
3
+ Open-source JSON Resume theme extracted from the private CV repository.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install jsonresume-theme-wintermuted
9
+ ```
10
+
11
+ Also install the shared design-token package used by this theme:
12
+
13
+ ```bash
14
+ npm install @wintermuted/ui-theme
15
+ ```
16
+
17
+ For local development before publish:
18
+
19
+ ```bash
20
+ npm install ../jsonresume-theme-wintermuted
21
+ ```
22
+
23
+ ## Usage with resumed
24
+
25
+ ```bash
26
+ resumed render resume.json -t jsonresume-theme-wintermuted -o resume.html
27
+ ```
28
+
29
+ ## What this package contains
30
+
31
+ - `resume.hbs` main Handlebars template
32
+ - `partials/` section partials
33
+ - `helpers/` helper functions
34
+ - `style.css` theme-specific styles
35
+ - Runtime CSS token inlining from `@wintermuted/ui-theme`
36
+
37
+ ## Publish
38
+
39
+ ```bash
40
+ npm publish --access public
41
+ ```
42
+
43
+ If you publish through GitHub Actions, configure the workflow to run `npm publish` on tags.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Format an ISO date string as "Mon YYYY".
3
+ * @param {string} dateStr
4
+ * @returns {string}
5
+ */
6
+ export function formatMonthYear(dateStr) {
7
+ const d = new Date(dateStr + 'T00:00:00');
8
+ return d.toLocaleDateString('en-US', { month: 'short', year: 'numeric' });
9
+ }
10
+
11
+ /**
12
+ * Format an ISO date string as "YYYY".
13
+ * @param {string} dateStr
14
+ * @returns {string}
15
+ */
16
+ export function formatYear(dateStr) {
17
+ return new Date(dateStr + 'T00:00:00').getFullYear().toString();
18
+ }
@@ -0,0 +1,18 @@
1
+ import { formatMonthYear, formatYear } from './date-helpers.js';
2
+ import { nestedWork } from './nested-work.js';
3
+ import { slugify, linkProjects } from './link-projects.js';
4
+ import { projectsForRole, roleMetaSummary, positionsForProject, projectMetaSummary } from './projects-for-role.js';
5
+ import { projectsByCategory } from './projects-by-category.js';
6
+
7
+ export default {
8
+ MY: formatMonthYear,
9
+ Y: formatYear,
10
+ nestedWork,
11
+ slugify,
12
+ linkProjects,
13
+ projectsForRole,
14
+ roleMetaSummary,
15
+ positionsForProject,
16
+ projectMetaSummary,
17
+ projectsByCategory,
18
+ };
@@ -0,0 +1,52 @@
1
+ import handlebars from 'handlebars';
2
+
3
+ /**
4
+ * Slugify a project name into an HTML-safe id fragment.
5
+ * "Deal Monitoring UI" → "deal-monitoring-ui"
6
+ */
7
+ export function slugify(str) {
8
+ return str
9
+ .toLowerCase()
10
+ .replace(/[^a-z0-9]+/g, '-')
11
+ .replace(/(^-|-$)/g, '');
12
+ }
13
+
14
+ /**
15
+ * Scan text for known project names (and aliases) and wrap first occurrence
16
+ * of each in an anchor link pointing to #project-<slug>.
17
+ * Returns an HTML SafeString (triple-stash {{{...}}} required).
18
+ */
19
+ export function linkProjects(text, projects) {
20
+ if (!text || !projects || !projects.length) return text;
21
+
22
+ let result = escapeHtml(text);
23
+
24
+ for (const project of projects) {
25
+ const slug = slugify(project.name);
26
+ // Build list of names to match: canonical name first, then aliases
27
+ const names = [project.name, ...(project._aliases || [])];
28
+
29
+ for (const name of names) {
30
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
31
+ // Word-boundary match to avoid partial matches inside longer words
32
+ const re = new RegExp(`\\b(${escaped})\\b`, 'i');
33
+ if (re.test(result)) {
34
+ result = result.replace(
35
+ re,
36
+ `<a href="#project-${slug}" class="project-ref">$1</a>`
37
+ );
38
+ break; // Only link first matching variant per project
39
+ }
40
+ }
41
+ }
42
+
43
+ return new handlebars.SafeString(result);
44
+ }
45
+
46
+ function escapeHtml(str) {
47
+ return str
48
+ .replace(/&/g, '&amp;')
49
+ .replace(/</g, '&lt;')
50
+ .replace(/>/g, '&gt;')
51
+ .replace(/"/g, '&quot;');
52
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Groups consecutive work entries sharing the same company into nested objects.
3
+ * Each group has { name, location, url, description, items: [...roles] }.
4
+ *
5
+ * @param {Array} workArray
6
+ * @param {object} options - Handlebars block options
7
+ * @returns {string}
8
+ */
9
+ export function nestedWork(workArray, options) {
10
+ const groups = workArray.reduce((acc, { location, description, name, url, ...rest }) => {
11
+ const prev = acc[acc.length - 1];
12
+ if (
13
+ prev &&
14
+ prev.name === name &&
15
+ prev.location === location &&
16
+ prev.description === description &&
17
+ prev.url === url
18
+ ) {
19
+ prev.items.push(rest);
20
+ } else {
21
+ acc.push({ location, description, name, url, items: [rest] });
22
+ }
23
+ return acc;
24
+ }, []);
25
+
26
+ return options.fn(groups);
27
+ }
@@ -0,0 +1,22 @@
1
+ export function projectsByCategory(projects, category) {
2
+ if (!Array.isArray(projects) || !category) {
3
+ return [];
4
+ }
5
+
6
+ var normalizedCategory = String(category).toLowerCase();
7
+
8
+ return projects.filter(function (project) {
9
+ var explicitCategory = project && project.projectCategory
10
+ ? String(project.projectCategory).toLowerCase()
11
+ : null;
12
+
13
+ if (explicitCategory) {
14
+ return explicitCategory === normalizedCategory;
15
+ }
16
+
17
+ // Backward-compatible fallback for older project entries.
18
+ var entity = project && project.entity ? String(project.entity).toLowerCase() : '';
19
+ var inferredCategory = entity === 'personal' ? 'open-source' : 'work';
20
+ return inferredCategory === normalizedCategory;
21
+ });
22
+ }
@@ -0,0 +1,134 @@
1
+ import { slugify } from './link-projects.js';
2
+
3
+ /**
4
+ * Returns projects whose entity matches the work company name
5
+ * and whose date range overlaps the role's date range.
6
+ *
7
+ * Usage (block helper):
8
+ * {{#projectsForRole companyName startDate endDate @root.resume.projects}}
9
+ * ... {{name}} {{slug}} ...
10
+ * {{/projectsForRole}}
11
+ */
12
+ export function projectsForRole(companyName, roleStart, roleEnd, projects, options) {
13
+ if (!projects || !projects.length || !companyName) return '';
14
+
15
+ const rStart = roleStart ? new Date(roleStart) : new Date(0);
16
+ const rEnd = roleEnd ? new Date(roleEnd) : new Date();
17
+
18
+ const matching = projects.filter((p) => {
19
+ if (p.entity !== companyName) return false;
20
+ const pStart = p.startDate ? new Date(p.startDate) : new Date(0);
21
+ const pEnd = p.endDate ? new Date(p.endDate) : new Date();
22
+ // Check date overlap: project starts before role ends AND project ends after role starts
23
+ return pStart <= rEnd && pEnd >= rStart;
24
+ });
25
+
26
+ if (!matching.length) return '';
27
+
28
+ return options.fn(matching);
29
+ }
30
+
31
+ /**
32
+ * Returns a formatted meta string like "4 projects · 16 skills" for a role.
33
+ * Omits project count if zero, omits skills count if zero.
34
+ */
35
+ export function roleMetaSummary(companyName, roleStart, roleEnd, projects, keywords) {
36
+ const parts = [];
37
+
38
+ if (projects && projects.length && companyName) {
39
+ const rStart = roleStart ? new Date(roleStart) : new Date(0);
40
+ const rEnd = roleEnd ? new Date(roleEnd) : new Date();
41
+ const count = projects.filter((p) => {
42
+ if (p.entity !== companyName) return false;
43
+ const pStart = p.startDate ? new Date(p.startDate) : new Date(0);
44
+ const pEnd = p.endDate ? new Date(p.endDate) : new Date();
45
+ return pStart <= rEnd && pEnd >= rStart;
46
+ }).length;
47
+ if (count > 0) parts.push(count + (count === 1 ? ' project' : ' projects'));
48
+ }
49
+
50
+ if (keywords && keywords.length) {
51
+ parts.push(keywords.length + (keywords.length === 1 ? ' skill' : ' skills'));
52
+ }
53
+
54
+ return parts.length ? ' · ' + parts.join(' · ') : '';
55
+ }
56
+
57
+ /**
58
+ * Returns matching role anchors for a work-related project based on company/entity
59
+ * and date overlap with resume work roles.
60
+ */
61
+ export function positionsForProject(project, work) {
62
+ if (!project || !Array.isArray(work) || !work.length || !project.entity) return [];
63
+
64
+ const pStart = project.startDate ? new Date(project.startDate) : new Date(0);
65
+ const pEnd = project.endDate ? new Date(project.endDate) : new Date();
66
+ const matches = [];
67
+ const groupedWork = work.reduce((acc, { location, description, name, url, ...rest }) => {
68
+ const prev = acc[acc.length - 1];
69
+ if (
70
+ prev &&
71
+ prev.name === name &&
72
+ prev.location === location &&
73
+ prev.description === description &&
74
+ prev.url === url
75
+ ) {
76
+ prev.items.push(rest);
77
+ } else {
78
+ acc.push({ location, description, name, url, items: [rest] });
79
+ }
80
+ return acc;
81
+ }, []);
82
+
83
+ groupedWork.forEach((company) => {
84
+ if (!company || company.name !== project.entity) return;
85
+ if (!Array.isArray(company.items)) return;
86
+
87
+ company.items.forEach((role, roleIndex) => {
88
+ if (!role) return;
89
+
90
+ const rStart = role.startDate ? new Date(role.startDate) : new Date(0);
91
+ const rEnd = role.endDate ? new Date(role.endDate) : new Date();
92
+ const overlaps = pStart <= rEnd && pEnd >= rStart;
93
+ if (!overlaps) return;
94
+
95
+ const roleName = role.position || 'Role';
96
+ const companyName = company.name || 'Company';
97
+ matches.push({
98
+ id: 'role-' +
99
+ slugify(companyName) +
100
+ '-' +
101
+ slugify(roleName) +
102
+ '-' +
103
+ roleIndex,
104
+ label: roleName + ' (' + companyName + ')',
105
+ });
106
+ });
107
+ });
108
+
109
+ return matches;
110
+ }
111
+
112
+ /**
113
+ * Returns a formatted meta string for project detail toggles, e.g.
114
+ * " · 4 gallery items · 9 skills".
115
+ */
116
+ export function projectMetaSummary(project) {
117
+ if (!project) return '';
118
+
119
+ const parts = [];
120
+ const imageCount = Array.isArray(project.images) ? project.images.length : 0;
121
+ const diagramCount = Array.isArray(project.diagrams) ? project.diagrams.length : 0;
122
+ const galleryCount = imageCount + diagramCount;
123
+ const skillCount = Array.isArray(project.keywords) ? project.keywords.length : 0;
124
+
125
+ if (galleryCount > 0) {
126
+ parts.push(galleryCount + (galleryCount === 1 ? ' gallery item' : ' gallery items'));
127
+ }
128
+
129
+ if (skillCount > 0) {
130
+ parts.push(skillCount + (skillCount === 1 ? ' skill' : ' skills'));
131
+ }
132
+
133
+ return parts.length ? ' · ' + parts.join(' · ') : '';
134
+ }
package/index.js ADDED
@@ -0,0 +1,98 @@
1
+ import handlebars from 'handlebars';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import helpers from './helpers/index.js';
5
+
6
+ /**
7
+ * @param {object} resume
8
+ * @returns {string}
9
+ */
10
+ export function render(resume) {
11
+ const css = fs.readFileSync(
12
+ path.join(import.meta.dirname, 'style.css'),
13
+ 'utf-8'
14
+ );
15
+
16
+ // Prepend the shared wintermuted UI theme (CSS variables + component classes).
17
+ // We inline nested @import directives so the exported HTML is fully self-contained.
18
+ let wmCss = '';
19
+ try {
20
+ const wmCssUrl = import.meta.resolve('@wintermuted/ui-theme/index.css');
21
+ wmCss = inlineCssImports(new URL(wmCssUrl)) + '\n';
22
+ } catch {
23
+ // import.meta.resolve can fail when the theme is loaded via a file: symlink chain
24
+ // (e.g. file:./themes/jsonresume-theme-local). Walk up the directory tree as fallback.
25
+ let dir = import.meta.dirname;
26
+ for (let i = 0; i < 6; i++) {
27
+ const candidate = path.join(dir, 'node_modules', '@wintermuted', 'ui-theme', 'index.css');
28
+ if (fs.existsSync(candidate)) {
29
+ wmCss = inlineCssImports(candidate) + '\n';
30
+ break;
31
+ }
32
+ const parent = path.dirname(dir);
33
+ if (parent === dir) break; // reached filesystem root
34
+ dir = parent;
35
+ }
36
+
37
+ // Local sibling fallback for workspace-style checkouts:
38
+ // /code/jsonresume-theme-wintermuted next to /code/wintermuted-ui-theme
39
+ if (!wmCss) {
40
+ const siblingCandidate = path.resolve(import.meta.dirname, '..', 'wintermuted-ui-theme', 'index.css');
41
+ if (fs.existsSync(siblingCandidate)) {
42
+ wmCss = inlineCssImports(siblingCandidate) + '\n';
43
+ }
44
+ }
45
+ }
46
+
47
+ const template = fs.readFileSync(
48
+ path.join(import.meta.dirname, 'resume.hbs'),
49
+ 'utf-8'
50
+ );
51
+
52
+ // Register partials
53
+ const partialsDir = path.join(import.meta.dirname, 'partials');
54
+ for (const filename of fs.readdirSync(partialsDir)) {
55
+ const match = /^([^.]+)\.hbs$/.exec(filename);
56
+ if (!match) continue;
57
+ const partial = fs.readFileSync(
58
+ path.join(partialsDir, filename),
59
+ 'utf-8'
60
+ );
61
+ handlebars.registerPartial(match[1], partial);
62
+ }
63
+
64
+ // Register helpers
65
+ for (const [name, helper] of Object.entries(helpers)) {
66
+ handlebars.registerHelper(name, helper);
67
+ }
68
+
69
+ // Build sections visibility map from resume.meta.hiddenSections
70
+ const allSections = [
71
+ 'summary', 'work', 'skills', 'projects',
72
+ 'education', 'volunteer', 'awards', 'languages', 'interests',
73
+ ];
74
+ const hidden = new Set(
75
+ (resume.meta && resume.meta.hiddenSections) || []
76
+ );
77
+ const sections = Object.fromEntries(
78
+ allSections.map((s) => [s, !hidden.has(s)])
79
+ );
80
+
81
+ return handlebars.compile(template)({ css: wmCss + css, resume, sections });
82
+ }
83
+
84
+ function inlineCssImports(entry, visited = new Set()) {
85
+ const entryPath = entry instanceof URL ? new URL(entry).pathname : path.resolve(entry);
86
+ if (visited.has(entryPath)) return '';
87
+ visited.add(entryPath);
88
+
89
+ const source = fs.readFileSync(entryPath, 'utf-8');
90
+ const importRegex = /^\s*@import\s+url\(["']([^"']+)["']\)\s*;\s*$/gm;
91
+
92
+ return source.replace(importRegex, (_full, importPath) => {
93
+ if (/^https?:\/\//i.test(importPath)) return '';
94
+ const nextPath = path.resolve(path.dirname(entryPath), importPath);
95
+ if (!fs.existsSync(nextPath)) return '';
96
+ return inlineCssImports(nextPath, visited);
97
+ });
98
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "jsonresume-theme-wintermuted",
3
+ "version": "0.1.0",
4
+ "description": "Wintermuted JSON Resume theme extracted from the CV project.",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "files": [
8
+ "index.js",
9
+ "style.css",
10
+ "resume.hbs",
11
+ "partials/**/*.hbs",
12
+ "helpers/**/*.js",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "keywords": [
17
+ "jsonresume",
18
+ "jsonresume-theme",
19
+ "resume",
20
+ "theme",
21
+ "wintermuted"
22
+ ],
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/wintermuted/jsonresume-theme-wintermuted.git"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/wintermuted/jsonresume-theme-wintermuted/issues"
30
+ },
31
+ "homepage": "https://github.com/wintermuted/jsonresume-theme-wintermuted#readme",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "handlebars": "^4.7.8"
37
+ }
38
+ }
@@ -0,0 +1,15 @@
1
+ {{#if resume.awards.length}}
2
+ <section class="section" id="awards">
3
+ <h2>Awards</h2>
4
+ {{#each resume.awards}}
5
+ <div class="award-entry" id="award-{{slugify title}}">
6
+ <div class="role-header">
7
+ <h4>{{ title }}</h4>
8
+ {{#if date}}<span class="date">{{MY date}}</span>{{/if}}
9
+ </div>
10
+ {{#if awarder}}<p class="awarder">{{ awarder }}</p>{{/if}}
11
+ {{#if summary}}<p>{{ summary }}</p>{{/if}}
12
+ </div>
13
+ {{/each}}
14
+ </section>
15
+ {{/if}}
@@ -0,0 +1,28 @@
1
+ {{#if resume.education.length}}
2
+ <section class="section" id="education">
3
+ <h2>Education</h2>
4
+ {{#each resume.education}}
5
+ <div class="education-entry" id="education-{{slugify institution}}">
6
+ <div class="role-header">
7
+ <h4>
8
+ {{#if url}}<a href="{{ url }}">{{ institution }}</a>{{else}}{{ institution }}{{/if}}
9
+ </h4>
10
+ <span class="date">
11
+ {{#if startDate}}{{MY startDate}}{{/if}}
12
+ {{#if endDate}} &ndash; {{MY endDate}}{{/if}}
13
+ </span>
14
+ </div>
15
+ <p>
16
+ {{#if studyType}}{{ studyType }}{{#if area}}, {{/if}}{{/if}}{{#if area}}{{ area }}{{/if}}
17
+ </p>
18
+ {{#if courses.length}}
19
+ <ul class="keywords">
20
+ {{#each courses}}
21
+ <li>{{ this }}</li>
22
+ {{/each}}
23
+ </ul>
24
+ {{/if}}
25
+ </div>
26
+ {{/each}}
27
+ </section>
28
+ {{/if}}
@@ -0,0 +1,19 @@
1
+ {{#if resume.interests.length}}
2
+ <section class="section" id="interests">
3
+ <h2>Interests</h2>
4
+ <div class="skills-grid">
5
+ {{#each resume.interests}}
6
+ <div class="skill-category">
7
+ {{#if name}}<h4>{{ name }}</h4>{{/if}}
8
+ {{#if keywords.length}}
9
+ <ul class="keywords">
10
+ {{#each keywords}}
11
+ <li>{{ this }}</li>
12
+ {{/each}}
13
+ </ul>
14
+ {{/if}}
15
+ </div>
16
+ {{/each}}
17
+ </div>
18
+ </section>
19
+ {{/if}}
@@ -0,0 +1,10 @@
1
+ {{#if resume.languages.length}}
2
+ <section class="section" id="languages">
3
+ <h2>Languages</h2>
4
+ <ul class="keywords">
5
+ {{#each resume.languages}}
6
+ <li>{{ language }}{{#if fluency}} <em>({{ fluency }})</em>{{/if}}</li>
7
+ {{/each}}
8
+ </ul>
9
+ </section>
10
+ {{/if}}