@lupinum/ginko-content 0.14.0 → 0.15.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/CHANGELOG.md +8 -0
- package/dist/index.mjs +9 -8
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lupinum/ginko-content
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92](https://github.com/lupinum-dev/ginko/pull/92) [`586e83a`](https://github.com/lupinum-dev/ginko/commit/586e83a0d3f04a5f61e002d7e6950855b61b2b22) Thanks [@Mat4m0](https://github.com/Mat4m0)! - Fix pages moving while images load: the card image (`::card{image}`) now gets the image's width and height (`imageWidth`, `imageHeight`), and so does the enlarged image of a figure.
|
|
8
|
+
- Updated dependencies [[`586e83a`](https://github.com/lupinum-dev/ginko/commit/586e83a0d3f04a5f61e002d7e6950855b61b2b22), [`586e83a`](https://github.com/lupinum-dev/ginko/commit/586e83a0d3f04a5f61e002d7e6950855b61b2b22)]:
|
|
9
|
+
- @lupinum/ginko@0.15.0
|
|
10
|
+
|
|
3
11
|
## 0.14.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, statSync, openSync, readSync, closeSync, existsSync, renameSync, mkdirSync } from 'node:fs';
|
|
2
2
|
import { readFile, readdir } from 'node:fs/promises';
|
|
3
3
|
import { resolve, sep, dirname, join, extname, basename } from 'node:path';
|
|
4
|
-
import { imageInfo, parseMarkdown, todayIn, validate, printOf, routeUrls, urlClashes, effectiveProfile, coreMessage, isDate, slugify, isTranslatable, sha256, resolveRouteLinks, isVisible, buildBundle } from '@lupinum/ginko/internal';
|
|
4
|
+
import { imageInfo, imageSizeProps, parseMarkdown, todayIn, validate, printOf, routeUrls, urlClashes, effectiveProfile, coreMessage, isDate, slugify, isTranslatable, sha256, resolveRouteLinks, isVisible, buildBundle } from '@lupinum/ginko/internal';
|
|
5
5
|
import { load } from 'js-yaml';
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
7
|
import { execFile } from 'node:child_process';
|
|
@@ -121,16 +121,17 @@ function rewriteImages(nodes, cx) {
|
|
|
121
121
|
} else if (Object.hasOwn(cx.imageProps, tag)) {
|
|
122
122
|
for (const prop of cx.imageProps[tag]) {
|
|
123
123
|
if (typeof node[1][prop] !== "string") continue;
|
|
124
|
-
rewriteImage(node[1], cx, prop,
|
|
124
|
+
rewriteImage(node[1], cx, prop, cx.sized[tag]?.includes(prop) ? "keep" : "none");
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
rewriteImages(node.slice(2), cx);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
function setSize(props, info, mode) {
|
|
130
|
+
function setSize(props, prop, info, mode) {
|
|
131
131
|
if (mode === "none") return;
|
|
132
|
-
|
|
133
|
-
if (mode === "set" || props
|
|
132
|
+
const [w, h] = imageSizeProps(prop);
|
|
133
|
+
if (mode === "set" || props[w] === void 0) props[w] = info.width;
|
|
134
|
+
if (mode === "set" || props[h] === void 0) props[h] = info.height;
|
|
134
135
|
}
|
|
135
136
|
function rewriteImage(props, cx, prop, mode) {
|
|
136
137
|
const src = props[prop];
|
|
@@ -140,7 +141,7 @@ function rewriteImage(props, cx, prop, mode) {
|
|
|
140
141
|
const root2 = resolve(cx.publicDir);
|
|
141
142
|
const abs2 = resolve(root2, clean.replace(/^\/+/, ""));
|
|
142
143
|
const info2 = abs2.startsWith(root2 + sep) && isFile(abs2) ? imageInfo(head(abs2, 64 * 1024)) : void 0;
|
|
143
|
-
if (info2) setSize(props, info2, mode);
|
|
144
|
+
if (info2) setSize(props, prop, info2, mode);
|
|
144
145
|
return;
|
|
145
146
|
}
|
|
146
147
|
const root = resolve(cx.contentDir);
|
|
@@ -161,7 +162,7 @@ function rewriteImage(props, cx, prop, mode) {
|
|
|
161
162
|
cx.images.set(url, abs);
|
|
162
163
|
cx.renames.set(src, url);
|
|
163
164
|
props[prop] = url;
|
|
164
|
-
setSize(props, info, mode);
|
|
165
|
+
setSize(props, prop, info, mode);
|
|
165
166
|
const copies = mode === "set" ? variantFiles(abs, hash, info.width) : [];
|
|
166
167
|
if (copies.length) {
|
|
167
168
|
props.srcset = [...copies.map((c) => `${IMAGE_URL_PREFIX}${c.name} ${c.width}w`), `${url} ${info.width}w`].join(", ");
|
|
@@ -491,7 +492,7 @@ async function readContent(contentDir, publicDir, schema, options = {}) {
|
|
|
491
492
|
const images = /* @__PURE__ */ new Map();
|
|
492
493
|
const components = Object.entries(schema.components ?? {});
|
|
493
494
|
const imageProps = Object.fromEntries(components.map(([tag, def]) => [tag, Object.entries(def.props ?? {}).filter(([, field]) => field.type === "image").map(([name]) => name)]));
|
|
494
|
-
const sized =
|
|
495
|
+
const sized = Object.fromEntries(components.map(([tag, def]) => [tag, imageProps[tag].filter((prop) => imageSizeProps(prop).every((p) => Object.hasOwn(def.props ?? {}, p)))]));
|
|
495
496
|
const main = schema.locales[0];
|
|
496
497
|
const times = await fileTimes(contentDir);
|
|
497
498
|
const urlOwners = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lupinum/ginko-content",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ginko bricks from Markdown files in the site's repo. Installed, not imported: the Ginko module loads it.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"shiki": "^4.3.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lupinum/ginko": "0.
|
|
39
|
+
"@lupinum/ginko": "0.15.0",
|
|
40
40
|
"sharp": "0.35.5",
|
|
41
41
|
"unbuild": "3.6.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@lupinum/ginko": "^0.
|
|
44
|
+
"@lupinum/ginko": "^0.15.0",
|
|
45
45
|
"sharp": "^0.33.0 || ^0.34.0 || ^0.35.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|