jeawin-astro 3.0.5 → 3.0.8
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/package.json +13 -10
- package/src/components/cards/news_grid_card1.astro +1 -1
- package/src/components/cards/news_grid_card5.astro +2 -2
- package/src/components/cards/news_list_card.astro +2 -2
- package/src/components/children_categories_list.astro +1 -1
- package/src/components/common_card.astro +3 -3
- package/src/components/index.ts +1 -0
- package/src/components/news_card.astro +2 -2
- package/src/components/product_card.astro +3 -3
- package/src/components/product_category_list.astro +1 -1
- package/src/components/search_pagefind.astro +71 -0
- package/src/integrations/index.ts +2 -1
- package/src/integrations/jeawin-astro-pagefind/index.ts +93 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jeawin-astro",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"author": "chaegumi <chaegumi@qq.com>",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"test": "mocha test"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.26.
|
|
29
|
-
"@babel/preset-env": "^7.26.
|
|
28
|
+
"@babel/core": "^7.26.9",
|
|
29
|
+
"@babel/preset-env": "^7.26.9",
|
|
30
30
|
"@rollup/plugin-babel": "^6.0.4",
|
|
31
31
|
"@rollup/plugin-commonjs": "^28.0.2",
|
|
32
32
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"@types/lodash": "^4.17.15",
|
|
39
39
|
"@types/sprintf-js": "^1.1.4",
|
|
40
40
|
"autoprefixer": "^10.4.20",
|
|
41
|
-
"chai": "^5.
|
|
41
|
+
"chai": "^5.2.0",
|
|
42
42
|
"mocha": "^10.8.2",
|
|
43
|
-
"postcss": "^8.5.
|
|
44
|
-
"rollup": "^4.34.
|
|
43
|
+
"postcss": "^8.5.2",
|
|
44
|
+
"rollup": "^4.34.8",
|
|
45
45
|
"rollup-plugin-node-externals": "^7.1.3",
|
|
46
46
|
"rollup-plugin-postcss": "^4.0.2",
|
|
47
47
|
"typescript": "^5.7.3"
|
|
@@ -58,13 +58,14 @@
|
|
|
58
58
|
"@iconify-json/fa6-solid": "^1.2.3",
|
|
59
59
|
"@iconify/tools": "^4.1.1",
|
|
60
60
|
"@keyv/compress-brotli": "^2.0.3",
|
|
61
|
+
"@pagefind/default-ui": "^1.3.0",
|
|
61
62
|
"@tailwindcss/forms": "^0.5.10",
|
|
62
63
|
"@tailwindcss/typography": "^0.5.16",
|
|
63
|
-
"@tailwindcss/vite": "^4.0.
|
|
64
|
+
"@tailwindcss/vite": "^4.0.6",
|
|
64
65
|
"@types/alpinejs": "^3.13.11",
|
|
65
66
|
"alpinejs": "^3.14.8",
|
|
66
67
|
"aos": "3.0.0-beta.6",
|
|
67
|
-
"astro": "^5.
|
|
68
|
+
"astro": "^5.3.0",
|
|
68
69
|
"astro-color-scheme": "^1.1.5",
|
|
69
70
|
"astro-embed": "^0.9.0",
|
|
70
71
|
"astro-icon": "^1.1.5",
|
|
@@ -77,13 +78,15 @@
|
|
|
77
78
|
"keyv": "^5.2.3",
|
|
78
79
|
"keyv-lru": "^3.0.4",
|
|
79
80
|
"lodash": "^4.17.21",
|
|
81
|
+
"pagefind": "^1.3.0",
|
|
80
82
|
"photoswipe": "^5.4.4",
|
|
83
|
+
"sirv": "^3.0.1",
|
|
81
84
|
"smartmenus": "2.0.0-alpha.1",
|
|
82
85
|
"sprintf-js": "^1.1.3",
|
|
83
86
|
"string-strip-html": "^13.4.8",
|
|
84
|
-
"swiper": "^11.2.
|
|
87
|
+
"swiper": "^11.2.4",
|
|
85
88
|
"tailwind-scrollbar": "^4.0.0",
|
|
86
|
-
"tailwindcss": "^4.0.
|
|
89
|
+
"tailwindcss": "^4.0.6",
|
|
87
90
|
"tslib": "^2.8.1"
|
|
88
91
|
}
|
|
89
92
|
}
|
|
@@ -48,7 +48,7 @@ const final_content = truncate(content, {
|
|
|
48
48
|
always_show_img ? (
|
|
49
49
|
<Fragment>
|
|
50
50
|
<div class="flex justify-center">
|
|
51
|
-
{img ? <JeawinImage img_html={img_html} /> : <DefaultImage />}
|
|
51
|
+
{img ? <JeawinImage img_html={img_html} add_classes="border border-gray-200" /> : <DefaultImage />}
|
|
52
52
|
</div>
|
|
53
53
|
</Fragment>
|
|
54
54
|
) : (
|
|
@@ -56,7 +56,7 @@ const final_content = truncate(content, {
|
|
|
56
56
|
always_show_img ? (
|
|
57
57
|
<Fragment>
|
|
58
58
|
{img ? (
|
|
59
|
-
<JeawinImage img_html={img_html} add_classes="card-img" />
|
|
59
|
+
<JeawinImage img_html={img_html} add_classes="card-img border border-gray-200" />
|
|
60
60
|
) : (
|
|
61
61
|
<DefaultImage class="card-img" />
|
|
62
62
|
)}
|
|
@@ -66,7 +66,7 @@ const final_content = truncate(content, {
|
|
|
66
66
|
{img ? (
|
|
67
67
|
<Fragment>
|
|
68
68
|
{!is_default_image(img) ? (
|
|
69
|
-
<JeawinImage img_html={img_html} add_classes="card-img" />
|
|
69
|
+
<JeawinImage img_html={img_html} add_classes="card-img border-gray-200" />
|
|
70
70
|
) : null}
|
|
71
71
|
</Fragment>
|
|
72
72
|
) : null}
|
|
@@ -40,7 +40,7 @@ const final_content = truncate(content, {
|
|
|
40
40
|
class="flex flex-col md:flex-row gap-5 border-b border-solid border-[#eee] mb-5 pb-5 p-2 md:py-8 md:px-4 bg-white rounded-lg shadow-lg transition-transform duration-300 hover:-translate-y-[5px]"
|
|
41
41
|
>
|
|
42
42
|
<div class="md:w-1/5">
|
|
43
|
-
{img ? <RenderImage img_html={img_html} /> : <DefaultImage />}
|
|
43
|
+
{img ? <RenderImage img_html={img_html} add_classes="border border-gray-200" /> : <DefaultImage />}
|
|
44
44
|
</div>
|
|
45
45
|
<div class="md:w-4/5">
|
|
46
46
|
{
|
|
@@ -48,7 +48,7 @@ const final_content = truncate(content, {
|
|
|
48
48
|
<div class="mb-3 text-sm text-[#6c757d]">{category_name}</div>
|
|
49
49
|
) : null
|
|
50
50
|
}
|
|
51
|
-
<TitleTag class="text-2xl mb-3
|
|
51
|
+
<TitleTag class="text-2xl mb-3">
|
|
52
52
|
<a href={render_url(node_url, base)} title={title}>{title}</a>
|
|
53
53
|
</TitleTag>
|
|
54
54
|
<div class="mb-3 text-sm text-[#666] leading-relaxed">
|
|
@@ -48,7 +48,7 @@ if (render_value(node, "content")) {
|
|
|
48
48
|
) : (
|
|
49
49
|
<a href={render_url(node.node_url, base)} title={node.node_title}>
|
|
50
50
|
{node.node_picurl ? (
|
|
51
|
-
<RenderImage img_html={node.node_picurl_html} />
|
|
51
|
+
<RenderImage img_html={node.node_picurl_html} add_classes="border border-gray-200" />
|
|
52
52
|
) : (
|
|
53
53
|
<DefaultImage />
|
|
54
54
|
)}
|
|
@@ -58,7 +58,7 @@ if (render_value(node, "content")) {
|
|
|
58
58
|
) : (
|
|
59
59
|
<a href={render_url(node.node_url, base)} title={node.node_title}>
|
|
60
60
|
{node.node_picurl ? (
|
|
61
|
-
<RenderImage img_html={node.node_picurl_html} />
|
|
61
|
+
<RenderImage img_html={node.node_picurl_html} add_classes="border border-gray-200" />
|
|
62
62
|
) : (
|
|
63
63
|
<DefaultImage />
|
|
64
64
|
)}
|
|
@@ -67,7 +67,7 @@ if (render_value(node, "content")) {
|
|
|
67
67
|
}
|
|
68
68
|
</div>
|
|
69
69
|
<div class="mt-7">
|
|
70
|
-
<TitleTag class="text-center
|
|
70
|
+
<TitleTag class="text-center">
|
|
71
71
|
<a href={render_url(node.node_url, base)} title={node.node_title}
|
|
72
72
|
>{node.node_title}</a
|
|
73
73
|
>
|
package/src/components/index.ts
CHANGED
|
@@ -38,6 +38,7 @@ export {default as RelNodesList} from "./rel_nodes_list.astro";
|
|
|
38
38
|
export {default as RemoteImage} from "./remote_image.astro";
|
|
39
39
|
export {default as SearchInput} from "./search_input.astro";
|
|
40
40
|
export {default as SearchResult} from "./search_result.astro";
|
|
41
|
+
export {default as SearchPagefind} from "./search_pagefind.astro";
|
|
41
42
|
export {default as SectionContainer} from "./section_container.astro";
|
|
42
43
|
export {default as ShareButton} from "./share_button.astro";
|
|
43
44
|
export {default as SidebarSub} from "./sidebar_sub.astro";
|
|
@@ -35,11 +35,11 @@ const TitleTag = title_tag || "div";
|
|
|
35
35
|
title={title}
|
|
36
36
|
class="flex items-center justify-center mb-3 h-full"
|
|
37
37
|
>
|
|
38
|
-
{img ? <RenderImage img_html={img_html} /> : <DefaultImage />}
|
|
38
|
+
{img ? <RenderImage img_html={img_html} add_classes="border border-gray-200" /> : <DefaultImage />}
|
|
39
39
|
</a>
|
|
40
40
|
|
|
41
41
|
<div class="text-[var(--themeColor)] mb-2">{category_name}</div>
|
|
42
|
-
<TitleTag class="
|
|
42
|
+
<TitleTag class="mb-3">
|
|
43
43
|
<a href={render_url(node_url, base)} title={title}>{title}</a>
|
|
44
44
|
</TitleTag>
|
|
45
45
|
<div class="flex items-center gap-3 text-[#6c757d] fill-[#6c757d] text-sm">
|
|
@@ -37,14 +37,14 @@ const RequestBtnText = render_value(all_langs, "request a quote");
|
|
|
37
37
|
<a
|
|
38
38
|
href={render_url(node_url, base)}
|
|
39
39
|
title={title}
|
|
40
|
-
class="flex items-center justify-center
|
|
40
|
+
class="flex items-center justify-center h-full"
|
|
41
41
|
>
|
|
42
|
-
{img ? <RenderImage img_html={img_html} /> : <DefaultImage />}
|
|
42
|
+
{img ? <RenderImage img_html={img_html} add_classes="border border-gray-200" /> : <DefaultImage />}
|
|
43
43
|
</a>
|
|
44
44
|
|
|
45
45
|
<div class="p-3">
|
|
46
46
|
<TitleTag
|
|
47
|
-
class="my-2 text-[#222]
|
|
47
|
+
class="my-2 text-[#222] hover:text-[#e53e3e] hover:underline"
|
|
48
48
|
>
|
|
49
49
|
<a href={render_url(node_url, base)} title={title} class="block text-center"
|
|
50
50
|
>{title}</a
|
|
@@ -81,7 +81,7 @@ switch (node_item_component) {
|
|
|
81
81
|
{
|
|
82
82
|
category.category_picurl_html ? (
|
|
83
83
|
<div class:list={["md:w-1/4", {'md:order-2':idx % 2 === 1}]}>
|
|
84
|
-
<JeawinImage img_html={category.category_picurl_html} add_classes="size-full" />
|
|
84
|
+
<JeawinImage img_html={category.category_picurl_html} add_classes="size-full border border-gray-200" />
|
|
85
85
|
</div>
|
|
86
86
|
) : null
|
|
87
87
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
import "@pagefind/default-ui/css/ui.css";
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
readonly id?: string;
|
|
6
|
+
readonly className?: string;
|
|
7
|
+
readonly query?: string;
|
|
8
|
+
readonly uiOptions?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { id, className, query, uiOptions = {} } = Astro.props;
|
|
12
|
+
const bundlePath = `${import.meta.env.BASE_URL}pagefind/`;
|
|
13
|
+
---
|
|
14
|
+
<section class="py-12">
|
|
15
|
+
<div class="max-w-screen-lg mx-auto">
|
|
16
|
+
<div class="px-4">
|
|
17
|
+
<div
|
|
18
|
+
id={id}
|
|
19
|
+
class:list={[className, "pagefind-init"]}
|
|
20
|
+
data-pagefind-ui
|
|
21
|
+
data-bundle-path={bundlePath}
|
|
22
|
+
data-query={query}
|
|
23
|
+
data-ui-options={JSON.stringify(uiOptions)}
|
|
24
|
+
>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</section>
|
|
29
|
+
<script>
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
import { PagefindUI } from "@pagefind/default-ui";
|
|
32
|
+
|
|
33
|
+
function initPageFind() {
|
|
34
|
+
const allSelector = "[data-pagefind-ui]";
|
|
35
|
+
for (const el of document.querySelectorAll(`${allSelector}.pagefind-init`)) {
|
|
36
|
+
const elSelector = [
|
|
37
|
+
...(el.id ? [`#${el.id}`] : []),
|
|
38
|
+
...[...el.classList.values()].map((c) => `.${c}`),
|
|
39
|
+
allSelector,
|
|
40
|
+
].join("");
|
|
41
|
+
const bundlePath = el.getAttribute("data-bundle-path");
|
|
42
|
+
const opts = JSON.parse(el.getAttribute("data-ui-options") ?? "{}");
|
|
43
|
+
new PagefindUI({
|
|
44
|
+
...opts,
|
|
45
|
+
element: elSelector,
|
|
46
|
+
bundlePath,
|
|
47
|
+
});
|
|
48
|
+
el.classList.remove("pagefind-init");
|
|
49
|
+
let query = el.getAttribute("data-query");
|
|
50
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
51
|
+
const params = Object.fromEntries(urlSearchParams.entries());
|
|
52
|
+
if(params.q){
|
|
53
|
+
query = params.q;
|
|
54
|
+
}
|
|
55
|
+
if (query) {
|
|
56
|
+
const input = el.querySelector<HTMLInputElement>(`input[type="text"]`);
|
|
57
|
+
if (input) {
|
|
58
|
+
input.value = query;
|
|
59
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
document.addEventListener("astro:page-load", initPageFind);
|
|
66
|
+
if (document.readyState === "loading") {
|
|
67
|
+
document.addEventListener("DOMContentLoaded", initPageFind);
|
|
68
|
+
} else {
|
|
69
|
+
initPageFind();
|
|
70
|
+
}
|
|
71
|
+
</script>
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {default as jeawinRuntimeConfig} from "./jeawin-runtime-config/index.ts";
|
|
1
|
+
export {default as jeawinRuntimeConfig} from "./jeawin-runtime-config/index.ts";
|
|
2
|
+
export {default as jeawinAstroPagefind} from "./jeawin-astro-pagefind/index.ts";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { AstroIntegration } from "astro";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { createIndex, type PagefindServiceConfig } from "pagefind";
|
|
5
|
+
import sirv from "sirv";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pagefind Astro integration options.
|
|
9
|
+
*/
|
|
10
|
+
export interface PagefindOptions {
|
|
11
|
+
/**
|
|
12
|
+
* `PagefindServiceConfig` passed to pagefind's `createIndex`
|
|
13
|
+
*/
|
|
14
|
+
indexConfig?: PagefindServiceConfig;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function pagefind({ indexConfig }: PagefindOptions = {}): AstroIntegration {
|
|
18
|
+
let outDir: string;
|
|
19
|
+
return {
|
|
20
|
+
name: "pagefind",
|
|
21
|
+
hooks: {
|
|
22
|
+
"astro:config:setup": ({ config, logger }: any) => {
|
|
23
|
+
if (config?.output === "server") {
|
|
24
|
+
logger.warn(
|
|
25
|
+
"Output type `server` does not produce static *.html pages in its output and thus will not work with astro-pagefind integration.",
|
|
26
|
+
);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (config.adapter?.name === "@astrojs/cloudflare") {
|
|
31
|
+
outDir = fileURLToPath(new URL(config.base?.replace(/^\//, ""), config.outDir));
|
|
32
|
+
} else if (config.adapter?.name === "@astrojs/node") {
|
|
33
|
+
outDir = fileURLToPath(config.build.client);
|
|
34
|
+
} else {
|
|
35
|
+
outDir = fileURLToPath(config.outDir);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"astro:server:setup": ({ server, logger }) => {
|
|
39
|
+
if (!outDir) {
|
|
40
|
+
logger.warn(
|
|
41
|
+
"astro-pagefind couldn't reliably determine the output directory. Search assets will not be served.",
|
|
42
|
+
);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const serve = sirv(outDir, {
|
|
47
|
+
dev: true,
|
|
48
|
+
etag: true,
|
|
49
|
+
});
|
|
50
|
+
server.middlewares.use((req, res, next) => {
|
|
51
|
+
if (req.url?.startsWith("/pagefind/")) {
|
|
52
|
+
serve(req, res, next);
|
|
53
|
+
} else {
|
|
54
|
+
next();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
"astro:build:done": async ({ logger }) => {
|
|
59
|
+
if (!outDir) {
|
|
60
|
+
logger.warn(
|
|
61
|
+
"astro-pagefind couldn't reliably determine the output directory. Search index will not be built.",
|
|
62
|
+
);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const { index, errors: createErrors } = await createIndex(indexConfig);
|
|
67
|
+
if (!index) {
|
|
68
|
+
logger.error("Pagefind failed to create index");
|
|
69
|
+
createErrors.forEach((e) => logger.error(e));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const { page_count, errors: addErrors } = await index.addDirectory({ path: outDir });
|
|
73
|
+
if (addErrors.length) {
|
|
74
|
+
logger.error("Pagefind failed to index files");
|
|
75
|
+
addErrors.forEach((e) => logger.error(e));
|
|
76
|
+
return;
|
|
77
|
+
} else {
|
|
78
|
+
logger.info(`Pagefind indexed ${page_count} pages`);
|
|
79
|
+
}
|
|
80
|
+
const { outputPath, errors: writeErrors } = await index.writeFiles({
|
|
81
|
+
outputPath: path.join(outDir, "pagefind"),
|
|
82
|
+
});
|
|
83
|
+
if (writeErrors.length) {
|
|
84
|
+
logger.error("Pagefind failed to write index");
|
|
85
|
+
writeErrors.forEach((e) => logger.error(e));
|
|
86
|
+
return;
|
|
87
|
+
} else {
|
|
88
|
+
logger.info(`Pagefind wrote index to ${outputPath}`);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|