@tideworthy/tidysites 0.1.20 → 0.1.21
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 +1 -1
- package/bin/tidysites.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ shows in `status`.
|
|
|
63
63
|
Styling: a row's `.css` file is scoped to that row (every rule is prefixed with the row's own selector), so it cannot style the rest of the page; rules for the whole page, the sections and the theme's classes go in `business/business.css`.
|
|
64
64
|
|
|
65
65
|
Images: an image field, a hero's image or a Columns image slot takes
|
|
66
|
-
`{ "$media": { "url": "https://...", "alt": "what it shows" } }` (or `{ "$media": { "file": "assets/x.png", "alt": "..." } }` for a picture that exists only as a file in the folder, say an illustration drawn from the old page's inline SVG; the push carries its bytes; a `file` field, such as a row's `media` list or the Business font files, takes a video (mp4, webm, up to
|
|
66
|
+
`{ "$media": { "url": "https://...", "alt": "what it shows" } }` (or `{ "$media": { "file": "assets/x.png", "alt": "..." } }` for a picture that exists only as a file in the folder, say an illustration drawn from the old page's inline SVG; the push carries its bytes; a `file` field, such as a row's `media` list or the Business font files, takes a video (mp4, webm, up to 25 MB, the most one file of a published site may weigh), a font (woff2) or a pdf the same way) and the
|
|
67
67
|
push fetches the file into the website's library; a file the library already
|
|
68
68
|
holds (the same bytes) is reused, not added again. An image already in the
|
|
69
69
|
library keeps the value the pull gave it.
|
package/bin/tidysites.mjs
CHANGED
|
@@ -399,8 +399,8 @@ async function push(ctx) {
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
const MEDIA_TYPES = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp', avif: 'image/avif', svg: 'image/svg+xml', ico: 'image/x-icon', mp4: 'video/mp4', m4v: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime', woff2: 'font/woff2', woff: 'font/woff', ttf: 'font/ttf', otf: 'font/otf', pdf: 'application/pdf' };
|
|
402
|
-
/** Pictures travel up to 15 MB; a video
|
|
403
|
-
const mediaCap = (type) => (type.startsWith('video/') ?
|
|
402
|
+
/** Pictures travel up to 15 MB; a video up to 25 MB, the most one file of a published site may weigh. */
|
|
403
|
+
const mediaCap = (type) => (type.startsWith('video/') ? 25 : 15);
|
|
404
404
|
/** Every { "$media": { "file": ... } } in the document becomes { "$media": { "data", "type", "filename", "alt" } }, read from the folder. */
|
|
405
405
|
function inlineMediaFiles(doc, dir) {
|
|
406
406
|
const walk = (v) => {
|
|
@@ -414,7 +414,7 @@ function inlineMediaFiles(doc, dir) {
|
|
|
414
414
|
const bytes = readFileSync(path);
|
|
415
415
|
const ext = m.file.split('.').pop().toLowerCase();
|
|
416
416
|
const type = MEDIA_TYPES[ext] ?? 'application/octet-stream';
|
|
417
|
-
if (bytes.length > mediaCap(type) * 1024 * 1024) fail(`$media.file ${m.file}: ${(bytes.length / 1048576).toFixed(1)} MB; ${type.startsWith('video/') ? 'videos up to
|
|
417
|
+
if (bytes.length > mediaCap(type) * 1024 * 1024) fail(`$media.file ${m.file}: ${(bytes.length / 1048576).toFixed(1)} MB; ${type.startsWith('video/') ? 'videos up to 25 MB (the most one file of a published site may weigh; re-encode it smaller)' : 'pictures up to 15 MB'}`);
|
|
418
418
|
return { $media: { data: bytes.toString('base64'), type, filename: m.file.split('/').pop(), alt: typeof m.alt === 'string' ? m.alt : '' } };
|
|
419
419
|
}
|
|
420
420
|
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, walk(x)]));
|
package/package.json
CHANGED