astro-pure 1.0.0 → 1.2.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/LICENSE +202 -0
- package/README.md +53 -0
- package/bun.lockb +0 -0
- package/components/advanced/Comment.astro +2 -2
- package/components/advanced/QRCode.astro +3 -17
- package/components/advanced/Quote.astro +3 -1
- package/components/basic/Footer.astro +73 -0
- package/components/basic/Header.astro +207 -0
- package/components/basic/ThemeProvider.astro +39 -0
- package/components/basic/index.ts +3 -0
- package/components/pages/ArticleBottom.astro +95 -0
- package/components/pages/BackToTop.astro +70 -0
- package/components/pages/Copyright.astro +144 -0
- package/components/pages/Hero.astro +150 -0
- package/components/pages/PageInfo.astro +18 -0
- package/components/pages/Paginator.astro +33 -0
- package/components/pages/PostPreview.astro +175 -0
- package/components/pages/TOC.astro +129 -0
- package/components/pages/TOCHeading.astro +37 -0
- package/components/pages/index.ts +9 -0
- package/components/user/Button.astro +2 -2
- package/components/user/CardList.astro +1 -2
- package/components/user/CardListChildren.astro +1 -2
- package/components/user/Icon.astro +34 -0
- package/components/user/Spoiler.astro +4 -1
- package/components/user/Tabs.astro +1 -1
- package/components/user/Timeline.astro +1 -1
- package/components/user/index.ts +3 -0
- package/index.ts +37 -8
- package/libs/icons.ts +106 -0
- package/libs/index.ts +1 -0
- package/package.json +25 -17
- package/plugins/remark-plugins.ts +13 -0
- package/plugins/virtual-user-config.ts +2 -8
- package/schemas/favicon.ts +1 -1
- package/schemas/header.ts +17 -0
- package/schemas/links.ts +28 -0
- package/schemas/locale.ts +29 -0
- package/schemas/logo.ts +2 -6
- package/schemas/share.ts +9 -0
- package/schemas/social.ts +6 -6
- package/scripts/index.js +37 -0
- package/scripts/libs/minimist.cjs +282 -0
- package/scripts/libs/slugify.cjs +73 -0
- package/scripts/new.mjs +111 -0
- package/types/index.ts +30 -0
- package/types/integrations-config.ts +18 -2
- package/types/{index.d.ts → module.d.ts} +0 -2
- package/types/theme-config.ts +162 -118
- package/types/user-config.ts +3 -1
- package/utils/date.ts +4 -4
- package/utils/error-map.ts +170 -0
- package/utils/index.ts +0 -12
- package/utils/server.ts +47 -0
- package/utils/theme.ts +1 -1
- package/virtual.d.ts +1 -2
- package/types/common.d.ts +0 -48
- package/utils/collections.ts +0 -48
- package/utils/docsContents.ts +0 -36
- package/utils/module.d.ts +0 -25
- /package/{utils → plugins}/toc.ts +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Astro Theme Pure
|
|
2
|
+
|
|
3
|
+
[](https://github.com/cworld1/astro-theme-pure/commits)
|
|
4
|
+
[](https://github.com/cworld1/astro-theme-pure/stargazers)
|
|
5
|
+
[](#)
|
|
6
|
+
[](https://github.com/cworld1/astro-theme-pure/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
A simple, fast and powerful blog theme built by Astro.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Use with theme template
|
|
15
|
+
|
|
16
|
+
See [Getting Started](https://astro-pure.js.org/docs/setup/getting-started).
|
|
17
|
+
|
|
18
|
+
### Use with common Astro project
|
|
19
|
+
|
|
20
|
+
Set up tailwindcss in your project.
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
// tailwind.config.mjs
|
|
24
|
+
|
|
25
|
+
/** @type {import('tailwindcss').Config} */
|
|
26
|
+
const config = {
|
|
27
|
+
content: [
|
|
28
|
+
// Add astro-pure components in the tailwindcss render config
|
|
29
|
+
'./node_modules/astro-pure/components/**/*.astro'
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default config
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
See [User Components](https://astro-pure.js.org/docs/integrations/components) & [Advanced Components](https://astro-pure.js.org/docs/integrations/advanced) to learn how to use.
|
|
37
|
+
|
|
38
|
+
> Some part of Advanced Components may require Astro Integration config.
|
|
39
|
+
|
|
40
|
+
## Cli
|
|
41
|
+
|
|
42
|
+
```shell
|
|
43
|
+
# See all commands
|
|
44
|
+
astro-pure help
|
|
45
|
+
# Get the info of astro-pure
|
|
46
|
+
astro-pure info
|
|
47
|
+
# Create a new post in the blog
|
|
48
|
+
astro-pure new [options]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
This project is licensed under the Apache 2.0 License.
|
package/bun.lockb
CHANGED
|
Binary file
|
|
@@ -61,7 +61,7 @@ const { class: className } = Astro.props
|
|
|
61
61
|
/* Font size */
|
|
62
62
|
--waline-font-size: 16px;
|
|
63
63
|
/* Basic color */
|
|
64
|
-
--waline-white: hsl(var(--background)
|
|
64
|
+
--waline-white: hsl(var(--background) / var(--tw-bg-opacity, 1));
|
|
65
65
|
--waline-light-grey: #999;
|
|
66
66
|
--waline-dark-grey: #666;
|
|
67
67
|
/* Theme color */
|
|
@@ -69,7 +69,7 @@ const { class: className } = Astro.props
|
|
|
69
69
|
--waline-active-color: hsl(var(--primary) / var(--tw-text-opacity, 1));
|
|
70
70
|
/* Layout */
|
|
71
71
|
--waline-color: hsl(var(--muted-foreground) / var(--tw-text-opacity, 1));
|
|
72
|
-
--waline-bg-color: hsl(var(--muted) / var(--tw-
|
|
72
|
+
--waline-bg-color: hsl(var(--muted) / var(--tw-bg-opacity, 1));
|
|
73
73
|
--waline-bg-color-light: hsl(var(--input) / var(--tw-text-opacity, 1));
|
|
74
74
|
--waline-bg-color-hover: #f0f0f0;
|
|
75
75
|
--waline-border-color: hsl(var(--border) / var(--tw-border-opacity, 1));
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import config from 'virtual:config'
|
|
3
3
|
|
|
4
|
-
const { content } = Astro.props
|
|
4
|
+
const { content, class: className, ...props } = Astro.props
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
<div
|
|
8
|
-
id='qrcode-container'
|
|
9
|
-
aria-expanded='false'
|
|
10
|
-
class='absolute z-10 -mt-2 box-content max-h-0 overflow-hidden rounded-xl border bg-muted p-4 opacity-0 transition-all duration-300 ease-in-out *:my-0 aria-expanded:max-h-[256px] aria-expanded:translate-y-4 aria-expanded:opacity-100'
|
|
11
|
-
>
|
|
12
|
-
</div>
|
|
7
|
+
<div id='qrcode-container' class={className} {...props}></div>
|
|
13
8
|
|
|
14
9
|
<script is:inline src={`${config.npmCDN}/qrcodejs/qrcode.min.js`}></script>
|
|
15
10
|
<script is:inline define:vars={{ content }}>
|
|
@@ -20,16 +15,7 @@ const { content } = Astro.props
|
|
|
20
15
|
if (qrcodeContainer.innerHTML !== '') return
|
|
21
16
|
new QRCode(qrcodeContainer, renderContent)
|
|
22
17
|
}
|
|
23
|
-
const getQRCode = document.getElementById('get-qrcode')
|
|
24
|
-
|
|
25
18
|
const qrcodeContainer = document.getElementById('qrcode-container')
|
|
26
19
|
if (!qrcodeContainer) throw new Error('qrcode container not found')
|
|
27
|
-
|
|
28
|
-
if (qrcodeContainer.ariaExpanded === 'true') {
|
|
29
|
-
qrcodeContainer.ariaExpanded = 'false'
|
|
30
|
-
} else {
|
|
31
|
-
loadqrcode(qrcodeContainer)
|
|
32
|
-
qrcodeContainer.ariaExpanded = 'true'
|
|
33
|
-
}
|
|
34
|
-
})
|
|
20
|
+
loadqrcode(qrcodeContainer)
|
|
35
21
|
</script>
|
|
@@ -35,9 +35,11 @@ const { class: className } = Astro.props
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
connectedCallback() {
|
|
38
|
+
// Because virtual:config can only be accessed using json string, function cannot work, so we need to use new Function
|
|
39
|
+
const targetFunction = new Function('return ' + quote.target)()
|
|
38
40
|
fetch(quote.server)
|
|
39
41
|
.then((response) => response.json())
|
|
40
|
-
.then((data) => this.render(
|
|
42
|
+
.then((data) => this.render(targetFunction(data)))
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
customElements.define('quote-component', Quote)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
import config from 'virtual:config'
|
|
3
|
+
|
|
4
|
+
import { Icon } from '../user'
|
|
5
|
+
|
|
6
|
+
const year = new Date().getFullYear()
|
|
7
|
+
const footerConf = config.footer
|
|
8
|
+
let social = footerConf.social || {}
|
|
9
|
+
|
|
10
|
+
// If the list does not contain rss, add it
|
|
11
|
+
social.rss = {
|
|
12
|
+
label: 'RSS',
|
|
13
|
+
url: '/rss.xml'
|
|
14
|
+
}
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<footer class='mx-auto mb-5 mt-16'>
|
|
18
|
+
<div class='border-t border-border pt-5'>
|
|
19
|
+
<div class='flex items-center gap-y-3 max-sm:flex-col sm:justify-between sm:gap-y-0'>
|
|
20
|
+
<div
|
|
21
|
+
class='flex items-center gap-x-4 gap-y-2 text-muted-foreground max-sm:flex-col [&_a:hover]:text-primary [&_a]:text-foreground'
|
|
22
|
+
>
|
|
23
|
+
{
|
|
24
|
+
footerConf.registration && (
|
|
25
|
+
<a
|
|
26
|
+
class='text-xs'
|
|
27
|
+
style='color:hsl(var(--muted-foreground)/var(--tw-text-opacity,1))'
|
|
28
|
+
href={footerConf.registration.url}
|
|
29
|
+
target='_blank'
|
|
30
|
+
>
|
|
31
|
+
{footerConf.registration.text}
|
|
32
|
+
</a>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
<span>
|
|
36
|
+
© {year}
|
|
37
|
+
{config.author} &
|
|
38
|
+
<a href='/terms/list'>Site policy</a>
|
|
39
|
+
</span>
|
|
40
|
+
{
|
|
41
|
+
footerConf.credits && (
|
|
42
|
+
<span class='text-muted-foreground [&_a:hover]:text-primary [&_a]:text-foreground'>
|
|
43
|
+
<a href='https://github.com/withastro/astro' target='_blank'>
|
|
44
|
+
Astro
|
|
45
|
+
</a>
|
|
46
|
+
&
|
|
47
|
+
<a href='https://github.com/cworld1/astro-theme-pure' target='_blank'>
|
|
48
|
+
Pure
|
|
49
|
+
</a>
|
|
50
|
+
theme powered
|
|
51
|
+
</span>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
{/* Social Brands */}
|
|
57
|
+
<div class='flex items-center gap-x-4'>
|
|
58
|
+
{
|
|
59
|
+
footerConf.social &&
|
|
60
|
+
Object.entries(footerConf.social).map(([platform, { label, url }]) => (
|
|
61
|
+
<a
|
|
62
|
+
class='inline-block text-muted-foreground transition-all hover:text-muted-foreground/75'
|
|
63
|
+
href={url}
|
|
64
|
+
aria-label={label}
|
|
65
|
+
>
|
|
66
|
+
<Icon class='size-6' name={platform as keyof typeof footerConf.social} />
|
|
67
|
+
</a>
|
|
68
|
+
))
|
|
69
|
+
}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</footer>
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
---
|
|
2
|
+
import config from 'virtual:config'
|
|
3
|
+
|
|
4
|
+
import { Icon } from '../user'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<header-component
|
|
8
|
+
class='group sticky top-4 z-30 mb-12 flex items-center justify-between rounded-xl border border-transparent max-sm:py-1 sm:rounded-2xl [&.not-top]:border-border [&.not-top]:bg-background [&.not-top]:px-1.5 dark:[&.not-top]:bg-muted'
|
|
9
|
+
>
|
|
10
|
+
<!-- <div
|
|
11
|
+
class='absolute -left-4 -top-8 -z-10 box-content hidden h-20 w-[calc(100%+2rem)] !duration-0 max-sm:group-[.expanded]:block max-sm:group-[.expanded.not-top]:hidden max-sm:group-[.expanded]:bg-white dark:max-sm:group-[.expanded]:bg-muted'
|
|
12
|
+
>
|
|
13
|
+
</div> -->
|
|
14
|
+
<a
|
|
15
|
+
class='z-30 text-xl font-semibold group-[.not-top]:ms-2 sm:group-[.not-top]:ms-3'
|
|
16
|
+
style='transition:margin-inline 0.3s'
|
|
17
|
+
href='/'
|
|
18
|
+
aria-label='Brand'>{config.title}</a
|
|
19
|
+
>
|
|
20
|
+
|
|
21
|
+
<div class='flex items-center gap-x-2'>
|
|
22
|
+
{/* Menu links */}
|
|
23
|
+
<div
|
|
24
|
+
id='headerExpandConetent'
|
|
25
|
+
class='end-0 start-0 top-12 grid border border-transparent group-[.not-top]:rounded-xl group-[.expanded]:opacity-100 dark:group-[.expanded.not-top]:bg-muted max-sm:absolute max-sm:opacity-0 max-sm:group-[.not-top]:border-border max-sm:group-[.expanded.not-top]:bg-background max-sm:group-[.not-top]:px-4 max-sm:group-[.not-top]:py-2 sm:grid-rows-1'
|
|
26
|
+
>
|
|
27
|
+
<div class='flex flex-col items-center justify-center overflow-hidden sm:flex-row'>
|
|
28
|
+
{
|
|
29
|
+
config.header.menu.map((item) => (
|
|
30
|
+
<a
|
|
31
|
+
href={item.link}
|
|
32
|
+
class='w-full flex-none grow py-2 text-right font-medium transition-none hover:text-primary sm:w-fit sm:px-3'
|
|
33
|
+
aria-label='Nav menu item'
|
|
34
|
+
>
|
|
35
|
+
{item.title}
|
|
36
|
+
</a>
|
|
37
|
+
))
|
|
38
|
+
}
|
|
39
|
+
<div class='flex w-full grow flex-row justify-end gap-x-3 sm:w-fit sm:gap-x-5'>
|
|
40
|
+
<a class='px-1 py-2 transition-none sm:px-2' href='/search' title='Search'>
|
|
41
|
+
<span class='sr-only'>Search</span>
|
|
42
|
+
<Icon name='search' class='size-5' />
|
|
43
|
+
</a>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<!-- buttons -->
|
|
49
|
+
<div class='z-30 flex gap-x-4 group-[.not-top]:gap-x-2' style='transition:gap 0.3s'>
|
|
50
|
+
<button
|
|
51
|
+
id='toggleDarkMode'
|
|
52
|
+
class='group/dark box-content size-5 rounded-md border p-1.5 transition-colors hover:bg-border sm:group-[.not-top]:rounded-xl'
|
|
53
|
+
>
|
|
54
|
+
<span class='sr-only'>Dark Theme</span>
|
|
55
|
+
<Icon class='system size-5 group-hover/dark:text-primary' name='computer' />
|
|
56
|
+
<Icon class='light hidden size-5 group-hover/dark:text-primary' name='sun' />
|
|
57
|
+
<Icon class='dark hidden size-5 group-hover/dark:text-primary' name='moon' />
|
|
58
|
+
</button>
|
|
59
|
+
<button
|
|
60
|
+
id='toggleMenu'
|
|
61
|
+
class='rounded-md border p-1.5 transition-colors hover:bg-border sm:hidden sm:group-[.not-top]:rounded-xl'
|
|
62
|
+
>
|
|
63
|
+
<span class='sr-only'>Menu</span>
|
|
64
|
+
<Icon class='size-5' name='menu' />
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</header-component>
|
|
69
|
+
|
|
70
|
+
{/* Use inline to load icon quicker firstly */}
|
|
71
|
+
<script is:inline>
|
|
72
|
+
const toggleDarkModeElement = document.getElementById('toggleDarkMode')
|
|
73
|
+
if (toggleDarkModeElement) {
|
|
74
|
+
toggleDarkModeElement.dataset.theme = localStorage.getItem('theme') || 'system'
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
<script>
|
|
78
|
+
import { setTheme, showToast } from '../../utils'
|
|
79
|
+
|
|
80
|
+
class Header extends HTMLElement {
|
|
81
|
+
constructor() {
|
|
82
|
+
super()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
connectedCallback() {
|
|
86
|
+
// Header
|
|
87
|
+
let preScrollY = window.scrollY
|
|
88
|
+
this.classList.toggle('not-top', preScrollY > 20)
|
|
89
|
+
window.addEventListener('scroll', () => {
|
|
90
|
+
this.classList.toggle('not-top', window.scrollY > 20)
|
|
91
|
+
this.dataset.show = (window.scrollY < 350 || window.scrollY < preScrollY).toString()
|
|
92
|
+
preScrollY = window.scrollY
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// Dark Mode
|
|
96
|
+
const darkModeBtn = this.querySelector('#toggleDarkMode') as HTMLElement
|
|
97
|
+
darkModeBtn.addEventListener('click', () => {
|
|
98
|
+
// Old way: dispatch event
|
|
99
|
+
// const toggleDarkModeEvent = new CustomEvent('theme-change', {
|
|
100
|
+
// detail: { theme: localStorage.getItem('theme') === 'light' ? 'dark' : 'light' }
|
|
101
|
+
// })
|
|
102
|
+
// document.dispatchEvent(toggleDarkModeEvent)
|
|
103
|
+
const newTheme = setTheme(undefined, true)
|
|
104
|
+
darkModeBtn.dataset.theme = newTheme
|
|
105
|
+
showToast({ message: `Set theme to ${newTheme}` })
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
// Menu
|
|
109
|
+
this.querySelector('#toggleMenu')?.addEventListener('click', () => {
|
|
110
|
+
this.classList.toggle('expanded')
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
customElements.define('header-component', Header)
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<style>
|
|
119
|
+
header-component {
|
|
120
|
+
transition:
|
|
121
|
+
padding 0.3s,
|
|
122
|
+
transform 0.3s,
|
|
123
|
+
margin-inline 0.3s,
|
|
124
|
+
border 0.15s,
|
|
125
|
+
background-color 0.15s;
|
|
126
|
+
|
|
127
|
+
&.not-top {
|
|
128
|
+
box-shadow:
|
|
129
|
+
rgb(255, 255, 255) 0px 0px 0px 0px,
|
|
130
|
+
rgba(24, 24, 27, 0.08) 0px 0px 0px 1px,
|
|
131
|
+
rgba(39, 39, 42, 0.08) 0px 10px 15px -3px,
|
|
132
|
+
rgba(39, 39, 42, 0.08) 0px 4px 6px -4px;
|
|
133
|
+
}
|
|
134
|
+
&[data-show='false']:not(.expanded) {
|
|
135
|
+
transform: translateY(-5rem);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
@media (min-width: 800px) {
|
|
139
|
+
header-component.not-top {
|
|
140
|
+
margin-inline: 8%;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* header menu */
|
|
145
|
+
@media (max-width: 640px) {
|
|
146
|
+
#headerExpandConetent {
|
|
147
|
+
grid-template-rows: 0fr;
|
|
148
|
+
transition:
|
|
149
|
+
opacity 0.3s,
|
|
150
|
+
padding 0.3s,
|
|
151
|
+
border-color 0.15s,
|
|
152
|
+
grid-template-rows 0.3s;
|
|
153
|
+
}
|
|
154
|
+
.expanded #headerExpandConetent {
|
|
155
|
+
grid-template-rows: 1fr;
|
|
156
|
+
}
|
|
157
|
+
.expanded.not-top #headerExpandConetent {
|
|
158
|
+
box-shadow:
|
|
159
|
+
rgb(255, 255, 255) 0px 0px 0px 0px,
|
|
160
|
+
rgba(24, 24, 27, 0.08) 0px 0px 0px 1px,
|
|
161
|
+
rgba(39, 39, 42, 0.08) 0px 10px 15px -3px,
|
|
162
|
+
rgba(39, 39, 42, 0.08) 0px 4px 6px -4px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* header component after */
|
|
166
|
+
header-component #headerExpandConetent::after {
|
|
167
|
+
box-sizing: content-box;
|
|
168
|
+
content: '';
|
|
169
|
+
position: absolute;
|
|
170
|
+
inset-inline: calc(-1rem - 1px);
|
|
171
|
+
bottom: 0;
|
|
172
|
+
top: -5rem;
|
|
173
|
+
z-index: -1;
|
|
174
|
+
transition: 0.3s;
|
|
175
|
+
visibility: hidden;
|
|
176
|
+
opacity: 0;
|
|
177
|
+
border-bottom: 1px solid transparent;
|
|
178
|
+
}
|
|
179
|
+
header-component:not(.not-top) #headerExpandConetent::after {
|
|
180
|
+
visibility: visible;
|
|
181
|
+
bottom: -1rem;
|
|
182
|
+
opacity: 1;
|
|
183
|
+
background-color: hsl(var(--muted) / var(--tw-bg-opacity, 1));
|
|
184
|
+
border-bottom-color: hsl(var(--border) / var(--tw-border-opacity, 1));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* dark light mode toggle */
|
|
189
|
+
#toggleDarkMode {
|
|
190
|
+
&[data-theme='dark'] {
|
|
191
|
+
& .system {
|
|
192
|
+
display: none;
|
|
193
|
+
}
|
|
194
|
+
& .dark {
|
|
195
|
+
display: block;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
&[data-theme='light'] {
|
|
199
|
+
& .system {
|
|
200
|
+
display: none;
|
|
201
|
+
}
|
|
202
|
+
.light {
|
|
203
|
+
display: block;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
{/* Use inline mode to quick load color, which can avoid splash */}
|
|
6
|
+
<script is:inline>
|
|
7
|
+
function simpleSetTheme() {
|
|
8
|
+
let theme = localStorage.getItem('theme')
|
|
9
|
+
// If undefined or 'system', get from system
|
|
10
|
+
if (!theme || theme === 'system') {
|
|
11
|
+
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
12
|
+
}
|
|
13
|
+
document.documentElement.classList.toggle('dark', theme === 'dark')
|
|
14
|
+
document
|
|
15
|
+
.querySelector('meta[name="theme-color"]')
|
|
16
|
+
?.setAttribute('content', theme === 'dark' ? '#0B0B10' : '#FCFCFD')
|
|
17
|
+
}
|
|
18
|
+
simpleSetTheme()
|
|
19
|
+
document.addEventListener('astro:page-load', () => simpleSetTheme())
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import { listenThemeChange } from '../../utils'
|
|
24
|
+
|
|
25
|
+
// Listen for theme change event
|
|
26
|
+
listenThemeChange()
|
|
27
|
+
// Listen for toast event
|
|
28
|
+
document.addEventListener('toast', (e) => {
|
|
29
|
+
const { message } = (e as CustomEvent).detail
|
|
30
|
+
const toast = document.createElement('div')
|
|
31
|
+
toast.className =
|
|
32
|
+
'animate fixed bottom-8 z-20 px-4 py-2 bg-muted text-foreground rounded-lg border border-border shadow-lg flex items-center gap-2'
|
|
33
|
+
toast.innerHTML = `<svg class='size-6'><use href='/icons/ui.svg#mingcute-information-line' /></svg> <span>${message}</span>`
|
|
34
|
+
document.body.appendChild(toast)
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
toast.remove()
|
|
37
|
+
}, 3000)
|
|
38
|
+
})
|
|
39
|
+
</script>
|