kss-modern 0.0.43 → 0.0.45
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/README.md +15 -0
- package/dist/node/lib/index.mjs +38 -1
- package/dist/styleguide-assets/.vite/manifest.json +2 -2
- package/dist/styleguide-assets/{browser-WqBcffEc.js → browser-sbHfjbF0.js} +2490 -2157
- package/dist/styleguide-assets/{fullpage-BnZffO-C.js → fullpage-vgwUQzah.js} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,21 @@ Styleguide 2.1
|
|
|
69
69
|
.btn { /* styles */ }
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
## Markup Includes
|
|
73
|
+
|
|
74
|
+
The `Markup:` field accepts three formats. File paths are resolved relative to `contentDir`.
|
|
75
|
+
|
|
76
|
+
```scss
|
|
77
|
+
/* Inline HTML */
|
|
78
|
+
Markup: <button class="btn {{modifier_class}}">Click me</button>
|
|
79
|
+
|
|
80
|
+
/* Static .html file — contents are inlined as-is */
|
|
81
|
+
Markup: templates/components/badge.html
|
|
82
|
+
|
|
83
|
+
/* Static .pug file — compiled to HTML at build time */
|
|
84
|
+
Markup: templates/components/card.pug
|
|
85
|
+
```
|
|
86
|
+
|
|
72
87
|
## Development
|
|
73
88
|
|
|
74
89
|
```bash
|
package/dist/node/lib/index.mjs
CHANGED
|
@@ -172,6 +172,39 @@ function generateId() {
|
|
|
172
172
|
return value;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
const INSERT_MARKUP_REGEX = /<insert-markup>(\d+(?:\.\d+)*)(?:-(\d*))?<\/insert-markup>/g;
|
|
176
|
+
function resolveInsertMarkupInRepository(repository, sectionsById) {
|
|
177
|
+
for (const [id, entry] of repository) {
|
|
178
|
+
entry.markup = resolveMarkup(entry.markup, repository, sectionsById, /* @__PURE__ */ new Set([id]));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function resolveMarkup(markup, repository, sectionsById, visited) {
|
|
182
|
+
return markup.replace(INSERT_MARKUP_REGEX, (_match, refId, modifierIdxStr) => {
|
|
183
|
+
if (visited.has(refId))
|
|
184
|
+
return errorBlock(refId, `circular reference detected for section "${refId}"`);
|
|
185
|
+
const refEntry = repository.get(refId);
|
|
186
|
+
if (!refEntry)
|
|
187
|
+
return errorBlock(refId, `section "${refId}" not found`);
|
|
188
|
+
let inserted = refEntry.markup;
|
|
189
|
+
if (modifierIdxStr !== void 0 && modifierIdxStr !== "") {
|
|
190
|
+
const modifierIdx = Number(modifierIdxStr);
|
|
191
|
+
const refSection = sectionsById.get(refId);
|
|
192
|
+
const modifier = refSection?.modifiers[modifierIdx];
|
|
193
|
+
if (!modifier)
|
|
194
|
+
return errorBlock(refId, `modifier index ${modifierIdx} out of range for section "${refId}"`);
|
|
195
|
+
const className = modifier.name.replace(/^\./, "");
|
|
196
|
+
inserted = inserted.replaceAll("{{modifier_class}}", className);
|
|
197
|
+
}
|
|
198
|
+
const nextVisited = new Set(visited);
|
|
199
|
+
nextVisited.add(refId);
|
|
200
|
+
return resolveMarkup(inserted, repository, sectionsById, nextVisited);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function errorBlock(refId, message) {
|
|
204
|
+
console.warn(`[insert-markup] ${message}`);
|
|
205
|
+
return `<pre class="kss-modern-insert-markup-error" data-section-ref="${sanitizeSpecialCharacters(refId)}">[insert-markup] ${sanitizeSpecialCharacters(message)}</pre>`;
|
|
206
|
+
}
|
|
207
|
+
|
|
175
208
|
const accordionRenderer = (bodyContent, props) => {
|
|
176
209
|
const type = props.type || "info";
|
|
177
210
|
const title = props.title || "Click to expand";
|
|
@@ -925,7 +958,7 @@ async function generateFullPageFile(data) {
|
|
|
925
958
|
<link rel="icon" type="image/svg+xml" href="/styleguide-assets/favicon/fullpage-light.svg">
|
|
926
959
|
`}
|
|
927
960
|
${data.ogImageUrl ? `<meta property="og:image" content="${data.ogImageUrl}">` : ""}
|
|
928
|
-
<script type="module" src="/styleguide-assets/fullpage-
|
|
961
|
+
<script type="module" src="/styleguide-assets/fullpage-vgwUQzah.js"><\/script>
|
|
929
962
|
${computedStyleTags}
|
|
930
963
|
</head>
|
|
931
964
|
<body${data.page.bodyclass ? ` class="${data.page.bodyclass}"` : ""}>
|
|
@@ -2147,17 +2180,21 @@ async function buildStyleguide(config) {
|
|
|
2147
2180
|
const menuSectionMapping = [];
|
|
2148
2181
|
const fileWriteTasks = [];
|
|
2149
2182
|
let markupRepository = /* @__PURE__ */ new Map();
|
|
2183
|
+
const sectionsById = /* @__PURE__ */ new Map();
|
|
2150
2184
|
parsedContent.forEach((firstLevelSection) => {
|
|
2151
2185
|
firstLevelSection.sections.forEach((secondLevelSection) => {
|
|
2186
|
+
sectionsById.set(secondLevelSection.id, { modifiers: secondLevelSection.modifiers.map((m) => ({ name: m.value })) });
|
|
2152
2187
|
if (secondLevelSection.markup)
|
|
2153
2188
|
markupRepository.set(secondLevelSection.id, { markup: secondLevelSection.markup });
|
|
2154
2189
|
secondLevelSection.sections.forEach((thirdLevelSection) => {
|
|
2190
|
+
sectionsById.set(thirdLevelSection.id, { modifiers: thirdLevelSection.modifiers.map((m) => ({ name: m.value })) });
|
|
2155
2191
|
if (thirdLevelSection.markup)
|
|
2156
2192
|
markupRepository.set(thirdLevelSection.id, { markup: thirdLevelSection.markup });
|
|
2157
2193
|
});
|
|
2158
2194
|
});
|
|
2159
2195
|
});
|
|
2160
2196
|
markupRepository = await compilePugMarkup(config.mode, config.contentDir, markupRepository);
|
|
2197
|
+
resolveInsertMarkupInRepository(markupRepository, sectionsById);
|
|
2161
2198
|
parsedContent.forEach((firstLevelSection, indexFirstLevel) => {
|
|
2162
2199
|
searchSectionMapping[indexFirstLevel] = {
|
|
2163
2200
|
title: firstLevelSection.header,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"name": "utils"
|
|
21
21
|
},
|
|
22
22
|
"client/fullpage.ts": {
|
|
23
|
-
"file": "fullpage-
|
|
23
|
+
"file": "fullpage-vgwUQzah.js",
|
|
24
24
|
"name": "fullpage",
|
|
25
25
|
"src": "client/fullpage.ts",
|
|
26
26
|
"isEntry": true,
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
]
|
|
105
105
|
},
|
|
106
106
|
"node_modules/html-validate/dist/esm/browser.js": {
|
|
107
|
-
"file": "browser-
|
|
107
|
+
"file": "browser-sbHfjbF0.js",
|
|
108
108
|
"name": "browser",
|
|
109
109
|
"src": "node_modules/html-validate/dist/esm/browser.js",
|
|
110
110
|
"isDynamicEntry": true,
|