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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jeawin-astro",
3
- "version": "3.0.43",
3
+ "version": "3.0.44",
4
4
  "author": "chaegumi <chaegumi@qq.com>",
5
5
  "description": "",
6
6
  "license": "MIT",
@@ -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={`{showSearchForm:${show_search_box}}`} class="w-full" :class={`{'w-full':showSearchForm}`}>
15
- <Icon
16
- name="fa6-solid:magnifying-glass"
17
- class="md:hidden size-5"
18
- x-on:click="showSearchForm = !showSearchForm"
19
- x-show="!showSearchForm"
20
- />
21
- <form
22
- method="get"
23
- class="w-full hidden md:block"
24
- :class={`{'!block':showSearchForm}`}
25
- action="/search.html"
26
- data-astro-reload
27
- >
28
- <div class="flex items-center gap-4 w-full">
29
- <label class="relative block w-full">
30
- <span class="absolute inset-y-0 left-0 flex items-center pl-2">
31
- <Icon name="fa6-solid:magnifying-glass" class="size-4" />
32
- </span>
33
- <span class="sr-only">{searchLang}</span>
34
- <input
35
- type="text"
36
- name="q"
37
- class="block bg-white w-full border border-slate-300 rounded-md py-2 pl-9 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"
38
- placeholder={searchInputLang}
39
- autocomplete="off"
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
- </label>
42
- <Icon
43
- name="fa6-solid:xmark"
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: `/${viteBase ? `${viteBase}/` : ''}robots.txt`,
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: `/${viteBase ? `${viteBase}/` : ''}clear_cache`,
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: `/${viteBase ? `${viteBase}/` : ''}manifest.json`,
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: `/${viteBase ? `${viteBase}/` : ''}opensearch.xml`,
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: `/${viteBase ? `${viteBase}/` : ''}rss.xml`,
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: `/${viteBase ? `${viteBase}/` : ''}site.webmanifest`,
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: `/${viteBase ? `${viteBase}/` : ''}sitemap.txt`,
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: `/${viteBase ? `${viteBase}/` : ''}sitemap.xml`,
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: `/${viteBase ? `${viteBase}/` : ''}sitemap.xsl`,
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: `/${viteBase ? `${viteBase}/` : ''}sw.js`,
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: `/${viteBase ? `${viteBase}/` : ''}install_sw.html`,
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: `/${viteBase ? `${viteBase}/` : ''}google644a0e8e598e1092.html`,
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: `/${viteBase ? `${viteBase}/` : ''}googlef1564b538eef5383.html`,
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"