@daz4126/swifty 2.12.0 → 3.0.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/README.md +1 -1
- package/package.json +1 -1
- package/src/assets.js +30 -0
- package/src/client/IDIOMORPH-LICENSE.txt +13 -0
- package/src/client/idiomorph.esm.js +1385 -0
- package/src/client/swifty-navigation.js +399 -0
- package/src/config.js +14 -0
- package/src/init.js +3 -0
- package/src/layout.js +13 -8
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Swifty uses convention over configuration to make it super simple to build blazi
|
|
|
22
22
|
- **Word count & reading time** - Auto-calculated for blog posts
|
|
23
23
|
- **Previous/next navigation** - Auto-generated links between sibling pages
|
|
24
24
|
- **[Eta templating](https://eta.js.org/)** - Full JavaScript in templates with EJS syntax
|
|
25
|
-
- **
|
|
25
|
+
- **Idiomorph navigation** with optional intent prefetching for SPA-like transitions
|
|
26
26
|
|
|
27
27
|
## Quickstart
|
|
28
28
|
|
package/package.json
CHANGED
package/src/assets.js
CHANGED
|
@@ -2,9 +2,14 @@ import fs from "fs/promises";
|
|
|
2
2
|
import fsExtra from "fs-extra";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import sharp from "sharp";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
5
6
|
import { dirs, defaultConfig } from "./config.js";
|
|
6
7
|
import { mapLimit } from "./concurrency.js";
|
|
7
8
|
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
const clientAssetsDir = path.join(__dirname, "client");
|
|
12
|
+
|
|
8
13
|
// Get file modification timestamp for cache busting
|
|
9
14
|
const getFileMtime = async (filePath) => {
|
|
10
15
|
const stats = await fs.stat(filePath);
|
|
@@ -20,6 +25,7 @@ const validExtensions = {
|
|
|
20
25
|
const optimizableImageExtensions = [".jpg", ".jpeg", ".png"];
|
|
21
26
|
|
|
22
27
|
const getBuildConcurrency = () => defaultConfig.build_concurrency || 16;
|
|
28
|
+
const navigationEnabled = () => defaultConfig.morphing !== false;
|
|
23
29
|
|
|
24
30
|
const isDestinationFresh = async (source, destination) => {
|
|
25
31
|
try {
|
|
@@ -80,6 +86,29 @@ const ensureAndCopy = async (source, destination, validExts) => {
|
|
|
80
86
|
console.log(`No ${path.basename(source)} found in ${source}`);
|
|
81
87
|
}
|
|
82
88
|
};
|
|
89
|
+
|
|
90
|
+
const copyNavigationAssets = async (outputDir = dirs.dist) => {
|
|
91
|
+
if (!navigationEnabled()) return;
|
|
92
|
+
if (!(await fsExtra.pathExists(clientAssetsDir))) return;
|
|
93
|
+
|
|
94
|
+
const destination = path.join(outputDir, "swifty");
|
|
95
|
+
await fsExtra.ensureDir(destination);
|
|
96
|
+
|
|
97
|
+
const files = await fs.readdir(clientAssetsDir);
|
|
98
|
+
await mapLimit(
|
|
99
|
+
files,
|
|
100
|
+
async (file) => {
|
|
101
|
+
const sourcePath = path.join(clientAssetsDir, file);
|
|
102
|
+
const destinationPath = path.join(destination, file);
|
|
103
|
+
const copied = await copyIfStale(sourcePath, destinationPath);
|
|
104
|
+
if (copied) {
|
|
105
|
+
console.log(`Copied Swifty navigation asset ${file}`);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
getBuildConcurrency(),
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
83
112
|
const copyAssets = async (outputDir = dirs.dist) => {
|
|
84
113
|
await ensureAndCopy(
|
|
85
114
|
dirs.css,
|
|
@@ -87,6 +116,7 @@ const copyAssets = async (outputDir = dirs.dist) => {
|
|
|
87
116
|
validExtensions.css,
|
|
88
117
|
);
|
|
89
118
|
await ensureAndCopy(dirs.js, path.join(outputDir, "js"), validExtensions.js);
|
|
119
|
+
await copyNavigationAssets(outputDir);
|
|
90
120
|
};
|
|
91
121
|
async function optimizeImages(outputDir = dirs.dist) {
|
|
92
122
|
try {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Zero-Clause BSD
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for
|
|
5
|
+
any purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
|
|
8
|
+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
9
|
+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
|
10
|
+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
|
|
11
|
+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
|
12
|
+
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
13
|
+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|