jeawin-astro 3.0.43 → 3.0.44
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 +1 -1
- package/src/components/search_input.astro +54 -35
- package/src/integrations/jeawin-astro-toolbar/index.ts +1 -1
- package/src/integrations/jeawin-common-route/index.ts +13 -13
- package/src/integrations/jeawin-common-route/routes/robots.txt.ts +2 -2
- package/src/integrations/jeawin-common-route/routes/sitemap.xml.ts +3 -1
package/package.json
CHANGED
|
@@ -3,48 +3,67 @@ import { Icon } from "astro-icon/components";
|
|
|
3
3
|
import { render_value } from "../scripts/util.js";
|
|
4
4
|
interface Props {
|
|
5
5
|
show_search_box?: boolean;
|
|
6
|
+
search_icon_style?: string;
|
|
6
7
|
}
|
|
7
8
|
const { all_langs } = Astro.locals;
|
|
8
|
-
const {show_search_box = false} = Astro.props;
|
|
9
|
+
const {show_search_box = false, search_icon_style} = Astro.props;
|
|
9
10
|
const searchInputLang = render_value(all_langs, "Search by site");
|
|
10
11
|
const searchLang = render_value(all_langs, "Search");
|
|
11
12
|
---
|
|
12
13
|
|
|
13
14
|
<div>
|
|
14
|
-
<div x-data={`{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
>
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
15
|
+
<div x-data={`{
|
|
16
|
+
showSearchForm:${show_search_box},
|
|
17
|
+
openSearchForm(){
|
|
18
|
+
this.showSearchForm = !this.showSearchForm;
|
|
19
|
+
if(document.querySelector('#navbar-header')){
|
|
20
|
+
const navbarHeight = document.querySelector('#navbar-header').getBoundingClientRect().height;
|
|
21
|
+
this.$refs.searchFormWrapper.style.minHeight = Math.ceil(navbarHeight)+'px';
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
closeSearchForm(){
|
|
25
|
+
this.showSearchForm = !this.showSearchForm;
|
|
26
|
+
}
|
|
27
|
+
}`} class="w-full" :class={`{'w-full':showSearchForm}`}>
|
|
28
|
+
<div class="size-5">
|
|
29
|
+
<Icon
|
|
30
|
+
name="fa6-solid:magnifying-glass"
|
|
31
|
+
class:list={["size-5 cursor-pointer", {"md:hidden":show_search_box}, search_icon_style]}
|
|
32
|
+
x-on:click="openSearchForm"
|
|
33
|
+
x-show="!showSearchForm"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div x-ref="searchFormWrapper"
|
|
38
|
+
class:list={["w-full hidden shadow-lg", {"md:block":show_search_box}]}
|
|
39
|
+
:class={`{'!block fixed top-0 left-0 right-0 bg-white p-4 z-[2147483646]':showSearchForm}`}>
|
|
40
|
+
<form
|
|
41
|
+
method="get"
|
|
42
|
+
action="/search.html"
|
|
43
|
+
data-astro-reload
|
|
44
|
+
>
|
|
45
|
+
<div class="max-w-screen-xl mx-auto flex items-center gap-4 w-full">
|
|
46
|
+
<label class="relative block w-full">
|
|
47
|
+
|
|
48
|
+
<span class="sr-only">{searchLang}</span>
|
|
49
|
+
<input
|
|
50
|
+
type="text"
|
|
51
|
+
name="q"
|
|
52
|
+
class="block bg-white w-full border border-slate-300 rounded-md py-2 pr-3 shadow-xs placeholder:italic placeholder:text-slate-400 focus:outline-hidden focus:border-sky-500 focus:ring-sky-500 focus:ring-1 sm:text-sm"
|
|
53
|
+
placeholder={searchInputLang}
|
|
54
|
+
autocomplete="off" required="required"
|
|
55
|
+
/>
|
|
56
|
+
<button type="submit" class="cursor-pointer absolute inset-y-0 right-0 flex items-center pr-2">
|
|
57
|
+
<Icon name="fa6-solid:magnifying-glass" class="size-4" />
|
|
58
|
+
</button>
|
|
59
|
+
</label>
|
|
60
|
+
<Icon
|
|
61
|
+
name="fa6-solid:xmark"
|
|
62
|
+
class="size-5 text-red-500 cursor-pointer"
|
|
63
|
+
x-on:click="closeSearchForm"
|
|
40
64
|
/>
|
|
41
|
-
</
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class="size-5 md:hidden"
|
|
45
|
-
x-on:click="showSearchForm=false"
|
|
46
|
-
/>
|
|
47
|
-
</div>
|
|
48
|
-
</form>
|
|
65
|
+
</div>
|
|
66
|
+
</form>
|
|
67
|
+
</div>
|
|
49
68
|
</div>
|
|
50
69
|
</div>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @filesource
|
|
9
9
|
*/
|
|
10
10
|
import {defineIntegration, addVirtualImports,createResolver} from "astro-integration-kit";
|
|
11
|
-
const cacache = await import('cacache');
|
|
11
|
+
// const cacache = await import('cacache');
|
|
12
12
|
export default defineIntegration({
|
|
13
13
|
name: "jeawin-astro-toolbar",
|
|
14
14
|
setup({name}) {
|
|
@@ -35,47 +35,47 @@ export default defineIntegration({
|
|
|
35
35
|
// });
|
|
36
36
|
|
|
37
37
|
injectRoute({
|
|
38
|
-
pattern:
|
|
38
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}robots.txt`,
|
|
39
39
|
entrypoint: resolve('./routes/robots.txt.ts'),
|
|
40
40
|
prerender: true
|
|
41
41
|
});
|
|
42
42
|
injectRoute({
|
|
43
|
-
pattern:
|
|
43
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}clear_cache`,
|
|
44
44
|
entrypoint: resolve('./routes/clear_cache.ts'),
|
|
45
45
|
prerender: true
|
|
46
46
|
});
|
|
47
47
|
injectRoute({
|
|
48
|
-
pattern:
|
|
48
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}manifest.json`,
|
|
49
49
|
entrypoint: resolve('./routes/manifest.json.ts'),
|
|
50
50
|
prerender: true
|
|
51
51
|
});
|
|
52
52
|
injectRoute({
|
|
53
|
-
pattern:
|
|
53
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}opensearch.xml`,
|
|
54
54
|
entrypoint: resolve('./routes/opensearch.xml.ts'),
|
|
55
55
|
prerender: true
|
|
56
56
|
});
|
|
57
57
|
injectRoute({
|
|
58
|
-
pattern:
|
|
58
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}rss.xml`,
|
|
59
59
|
entrypoint: resolve('./routes/rss.xml.ts'),
|
|
60
60
|
prerender: true
|
|
61
61
|
});
|
|
62
62
|
injectRoute({
|
|
63
|
-
pattern:
|
|
63
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}site.webmanifest`,
|
|
64
64
|
entrypoint: resolve('./routes/site.webmanifest.ts'),
|
|
65
65
|
prerender: true
|
|
66
66
|
});
|
|
67
67
|
injectRoute({
|
|
68
|
-
pattern:
|
|
68
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}sitemap.txt`,
|
|
69
69
|
entrypoint: resolve('./routes/sitemap.txt.ts'),
|
|
70
70
|
prerender: true
|
|
71
71
|
});
|
|
72
72
|
injectRoute({
|
|
73
|
-
pattern:
|
|
73
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}sitemap.xml`,
|
|
74
74
|
entrypoint: resolve('./routes/sitemap.xml.ts'),
|
|
75
75
|
prerender: true
|
|
76
76
|
});
|
|
77
77
|
injectRoute({
|
|
78
|
-
pattern:
|
|
78
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}sitemap.xsl`,
|
|
79
79
|
entrypoint: resolve('./routes/sitemap.xsl.ts'),
|
|
80
80
|
prerender: true
|
|
81
81
|
});
|
|
@@ -83,12 +83,12 @@ export default defineIntegration({
|
|
|
83
83
|
if(options?.amp){
|
|
84
84
|
// AMP需要的文件
|
|
85
85
|
injectRoute({
|
|
86
|
-
pattern:
|
|
86
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}sw.js`,
|
|
87
87
|
entrypoint: resolve('./routes/sw.js.ts'),
|
|
88
88
|
prerender: true
|
|
89
89
|
});
|
|
90
90
|
injectRoute({
|
|
91
|
-
pattern:
|
|
91
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}install_sw.html`,
|
|
92
92
|
entrypoint: resolve('./routes/install_sw.html.ts'),
|
|
93
93
|
prerender: true
|
|
94
94
|
});
|
|
@@ -96,12 +96,12 @@ export default defineIntegration({
|
|
|
96
96
|
|
|
97
97
|
// 谷歌验证文件
|
|
98
98
|
injectRoute({
|
|
99
|
-
pattern:
|
|
99
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}google644a0e8e598e1092.html`,
|
|
100
100
|
entrypoint: resolve('./routes/google644a0e8e598e1092.html.ts'),
|
|
101
101
|
prerender: true
|
|
102
102
|
});
|
|
103
103
|
injectRoute({
|
|
104
|
-
pattern:
|
|
104
|
+
pattern: `${viteBase ? `${viteBase}/` : '/'}googlef1564b538eef5383.html`,
|
|
105
105
|
entrypoint: resolve('./routes/googlef1564b538eef5383.html.ts'),
|
|
106
106
|
prerender: true
|
|
107
107
|
});
|
|
@@ -5,7 +5,7 @@ Allow: /
|
|
|
5
5
|
Sitemap: ${sitemapURL.href}
|
|
6
6
|
`;
|
|
7
7
|
|
|
8
|
-
export const GET:APIRoute = ({site}) => {
|
|
9
|
-
const sitemapURL = new URL('sitemap.xml', site);
|
|
8
|
+
export const GET:APIRoute = ({site, locals}) => {
|
|
9
|
+
const sitemapURL = new URL((locals.base ? locals.base + '/' : '/')+'sitemap.xml', site);
|
|
10
10
|
return new Response(getRobotsTxt(sitemapURL));
|
|
11
11
|
}
|
|
@@ -4,8 +4,10 @@ import _ from 'lodash';
|
|
|
4
4
|
|
|
5
5
|
export const GET:APIRoute = async ({site, locals}) => {
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
|
|
7
9
|
let sitemapxml = `<?xml version="1.0" encoding="UTF-8" ?>
|
|
8
|
-
<?xml-stylesheet type="text/xsl" href="/sitemap.xsl" ?>
|
|
10
|
+
<?xml-stylesheet type="text/xsl" href="${locals.base ? `${locals.base}/` : '/'}sitemap.xsl" ?>
|
|
9
11
|
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
10
12
|
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
|
11
13
|
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd"
|