vite-plugin-vanjs 0.1.21 → 0.1.22
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/meta/tags.mjs +3 -3
- package/package.json +1 -1
- package/router/helpers.mjs +10 -6
- package/server/index.mjs +8 -0
package/meta/tags.mjs
CHANGED
|
@@ -43,14 +43,14 @@ export const Link = (props) => {
|
|
|
43
43
|
* Add a new `<script>` tag, not to be used for .js files
|
|
44
44
|
* Only to be used as `<script type="application/ld+json">`
|
|
45
45
|
* for SEO purposes.
|
|
46
|
-
* @type {(props: PropsWithKnownKeys<HTMLScriptElement
|
|
46
|
+
* @type {(props: PropsWithKnownKeys<HTMLScriptElement>, content: string) => null}
|
|
47
47
|
*/
|
|
48
|
-
export const Script = (props) => {
|
|
48
|
+
export const Script = (props, content) => {
|
|
49
49
|
const { script } = van.tags;
|
|
50
50
|
if (!props.type || props.type !== "application/ld+json") {
|
|
51
51
|
console.warn("Script doesn't support this type, check the Wiki.");
|
|
52
52
|
} else {
|
|
53
|
-
addMeta(script(props));
|
|
53
|
+
addMeta(script(props, content));
|
|
54
54
|
}
|
|
55
55
|
return null;
|
|
56
56
|
};
|
package/package.json
CHANGED
package/router/helpers.mjs
CHANGED
|
@@ -65,14 +65,18 @@ export const executeLifecycle = async (route, params) => {
|
|
|
65
65
|
const preload = route.preload;
|
|
66
66
|
const load = route.load;
|
|
67
67
|
|
|
68
|
+
const pathname = routerState.pathname;
|
|
69
|
+
const cacheKey = Object.keys(params || {}).length === 0
|
|
70
|
+
? ""
|
|
71
|
+
: JSON.stringify(params);
|
|
72
|
+
|
|
68
73
|
if (preload) await preload(params);
|
|
69
|
-
if (!data && load
|
|
74
|
+
if (!data && load && !dataCache.has(pathname, cacheKey)) {
|
|
75
|
+
data = await load(params);
|
|
76
|
+
} else if (load && dataCache.has(pathname, cacheKey)) {
|
|
77
|
+
dataCache.touch(pathname);
|
|
78
|
+
}
|
|
70
79
|
if (data) {
|
|
71
|
-
// initialLoaded = true;
|
|
72
|
-
const pathname = routerState.pathname;
|
|
73
|
-
const cacheKey = Object.keys(params || {}).length === 0
|
|
74
|
-
? ""
|
|
75
|
-
: JSON.stringify(params);
|
|
76
80
|
dataCache.set(pathname, cacheKey, {
|
|
77
81
|
data,
|
|
78
82
|
error: null,
|
package/server/index.mjs
CHANGED
|
@@ -58,6 +58,14 @@ function renderPreloadLink(file) {
|
|
|
58
58
|
return `<link rel="preload" href="${file}" as="font" type="font/woff" crossorigin>`;
|
|
59
59
|
} else if (file.endsWith(".woff2")) {
|
|
60
60
|
return `<link rel="preload" href="${file}" as="font" type="font/woff2" crossorigin>`;
|
|
61
|
+
} else if (file.endsWith(".gif")) {
|
|
62
|
+
return `<link rel="preload" href="${file}" as="image" type="image/gif" crossorigin>`;
|
|
63
|
+
} else if (file.endsWith(".jpg") || file.endsWith(".jpeg")) {
|
|
64
|
+
return `<link rel="preload" href="${file}" as="image" type="image/jpeg" crossorigin>`;
|
|
65
|
+
} else if (file.endsWith(".png")) {
|
|
66
|
+
return `<link rel="preload" href="${file}" as="image" type="image/png" crossorigin>`;
|
|
67
|
+
} else if (file.endsWith(".webp")) {
|
|
68
|
+
return `<link rel="preload" href="${file}" as="image" type="image/webp" crossorigin>`;
|
|
61
69
|
} else {
|
|
62
70
|
console.warn("Render error! File format not recognized: " + file);
|
|
63
71
|
return "";
|