ezal-theme-example 0.0.1

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.
Files changed (102) hide show
  1. package/LICENSE +21 -0
  2. package/assets/scripts/404.ts +353 -0
  3. package/assets/scripts/_article.ts +290 -0
  4. package/assets/scripts/_base.ts +65 -0
  5. package/assets/scripts/_pagefind.d.ts +424 -0
  6. package/assets/scripts/_search.ts +88 -0
  7. package/assets/scripts/_utils.ts +74 -0
  8. package/assets/scripts/archive.ts +143 -0
  9. package/assets/scripts/article.ts +18 -0
  10. package/assets/scripts/category.ts +4 -0
  11. package/assets/scripts/home.ts +73 -0
  12. package/assets/scripts/links.ts +14 -0
  13. package/assets/scripts/main.ts +11 -0
  14. package/assets/scripts/page.ts +11 -0
  15. package/assets/scripts/tag.ts +4 -0
  16. package/assets/scripts/tsconfig.json +10 -0
  17. package/assets/styles/404.styl +31 -0
  18. package/assets/styles/_article/fold.styl +15 -0
  19. package/assets/styles/_article/footnote.styl +12 -0
  20. package/assets/styles/_article/heading.styl +29 -0
  21. package/assets/styles/_article/image.styl +30 -0
  22. package/assets/styles/_article/kbd.styl +10 -0
  23. package/assets/styles/_article/links.styl +31 -0
  24. package/assets/styles/_article/list.styl +19 -0
  25. package/assets/styles/_article/note.styl +18 -0
  26. package/assets/styles/_article/other.styl +44 -0
  27. package/assets/styles/_article/table.styl +29 -0
  28. package/assets/styles/_article/tabs.styl +25 -0
  29. package/assets/styles/_code.styl +83 -0
  30. package/assets/styles/_index/contact.styl +20 -0
  31. package/assets/styles/_index/footer.styl +5 -0
  32. package/assets/styles/_index/header.styl +40 -0
  33. package/assets/styles/_index/nav.styl +59 -0
  34. package/assets/styles/_index/search.styl +64 -0
  35. package/assets/styles/_index.styl +91 -0
  36. package/assets/styles/_var.styl +96 -0
  37. package/assets/styles/archive.styl +35 -0
  38. package/assets/styles/article.styl +138 -0
  39. package/assets/styles/category.styl +4 -0
  40. package/assets/styles/home.styl +124 -0
  41. package/assets/styles/links.styl +121 -0
  42. package/assets/styles/page.styl +12 -0
  43. package/assets/styles/tag.styl +4 -0
  44. package/dist/config.d.ts +128 -0
  45. package/dist/feed.d.ts +4 -0
  46. package/dist/image/asset.d.ts +22 -0
  47. package/dist/image/db.d.ts +18 -0
  48. package/dist/image/index.d.ts +10 -0
  49. package/dist/image/metadata.d.ts +2 -0
  50. package/dist/image/utils.d.ts +1 -0
  51. package/dist/index-now.d.ts +1 -0
  52. package/dist/index.d.ts +3 -0
  53. package/dist/index.js +2066 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/layout.d.ts +2 -0
  56. package/dist/markdown/codeblock/data.d.ts +1 -0
  57. package/dist/markdown/codeblock/index.d.ts +6 -0
  58. package/dist/markdown/codeblock/style.d.ts +2 -0
  59. package/dist/markdown/fold.d.ts +6 -0
  60. package/dist/markdown/footnote.d.ts +15 -0
  61. package/dist/markdown/image.d.ts +12 -0
  62. package/dist/markdown/index.d.ts +2 -0
  63. package/dist/markdown/kbd.d.ts +6 -0
  64. package/dist/markdown/link.d.ts +2 -0
  65. package/dist/markdown/links.d.ts +12 -0
  66. package/dist/markdown/note.d.ts +8 -0
  67. package/dist/markdown/table.d.ts +3 -0
  68. package/dist/markdown/tabs.d.ts +7 -0
  69. package/dist/markdown/tex.d.ts +9 -0
  70. package/dist/page/404.d.ts +1 -0
  71. package/dist/page/archive.d.ts +1 -0
  72. package/dist/page/category.d.ts +1 -0
  73. package/dist/page/home.d.ts +2 -0
  74. package/dist/page/tag.d.ts +1 -0
  75. package/dist/pagefind.d.ts +20 -0
  76. package/dist/sitemap.d.ts +2 -0
  77. package/dist/transform/script.d.ts +2 -0
  78. package/dist/transform/stylus.d.ts +2 -0
  79. package/dist/utils.d.ts +2 -0
  80. package/layouts/404.tsx +8 -0
  81. package/layouts/archive.tsx +81 -0
  82. package/layouts/article.tsx +145 -0
  83. package/layouts/base.tsx +20 -0
  84. package/layouts/category.tsx +18 -0
  85. package/layouts/components/ArchiveArticleList.tsx +14 -0
  86. package/layouts/components/Article.tsx +46 -0
  87. package/layouts/components/Contact.tsx +14 -0
  88. package/layouts/components/Footer.tsx +44 -0
  89. package/layouts/components/Head.tsx +119 -0
  90. package/layouts/components/Image.tsx +42 -0
  91. package/layouts/components/Nav.tsx +33 -0
  92. package/layouts/components/Search.tsx +20 -0
  93. package/layouts/components/Waline.tsx +22 -0
  94. package/layouts/context.d.ts +54 -0
  95. package/layouts/home.tsx +74 -0
  96. package/layouts/links.tsx +53 -0
  97. package/layouts/page.tsx +19 -0
  98. package/layouts/tag.tsx +18 -0
  99. package/layouts/tsconfig.json +11 -0
  100. package/package.json +47 -0
  101. package/readme.md +17 -0
  102. package/readme_zh.md +17 -0
@@ -0,0 +1,121 @@
1
+ @import '_index'
2
+
3
+ // MARK: Header
4
+ header
5
+ img
6
+ filter blur(4px)
7
+ scale 1.05
8
+
9
+ .cates
10
+ display flex
11
+ flex-wrap wrap
12
+ font-weight bold
13
+ gap 4px 16px
14
+
15
+ .tag
16
+ &:before
17
+ content '#'
18
+ opacity .5
19
+
20
+ .article-info
21
+ display flex
22
+ flex-wrap wrap
23
+ gap 8px
24
+ :before
25
+ margin-right 4px
26
+
27
+ // MARK: Main
28
+ main
29
+ display flex
30
+ flex-direction row-reverse
31
+
32
+ article
33
+ flex 1
34
+ padding 8px
35
+ width 0
36
+ text-wrap pretty
37
+
38
+ .sticky
39
+ position sticky
40
+ top var(--sticky)
41
+ z-index 4
42
+ background var(--panel)
43
+ backdrop-filter blur(4px)
44
+ --sticky 0px
45
+
46
+ .sticky-content
47
+ .sticky
48
+ z-index 3
49
+ --sticky 40px
50
+ .sticky-content
51
+ .sticky
52
+ z-index 2
53
+ --sticky 80px
54
+ .sticky-content
55
+ .sticky
56
+ z-index 1
57
+ --sticky 80px
58
+ .sticky-content
59
+ .sticky
60
+ z-index 0
61
+ --sticky 80px
62
+
63
+ if linksStyle('heading')
64
+ @import '_article/heading'
65
+
66
+ @import '_article/other'
67
+
68
+ if linksStyle('image')
69
+ @import '_article/image'
70
+
71
+ if linksStyle('table')
72
+ @import '_article/table'
73
+
74
+ if linksStyle('list')
75
+ @import '_article/list'
76
+
77
+ if linksStyle('footnote')
78
+ @import '_article/footnote'
79
+
80
+ if linksStyle('tabs')
81
+ @import '_article/tabs'
82
+
83
+ if linksStyle('note')
84
+ @import '_article/note'
85
+
86
+ if linksStyle('fold')
87
+ @import '_article/fold'
88
+
89
+ if linksStyle('kbd')
90
+ @import '_article/kbd'
91
+
92
+ // MARK: Links
93
+ .links
94
+ margin 16px 0
95
+ text-align center
96
+ text-wrap balance
97
+ a
98
+ position relative
99
+ display inline-block
100
+ margin 8px
101
+ padding 16px
102
+ max-width 300px
103
+ width 100%
104
+ border 1px solid var(--border)
105
+ background var(--panel)
106
+ color var(--text)
107
+ text-align left
108
+ text-decoration none
109
+ transition .1s
110
+ &:hover
111
+ border-color var(--theme)
112
+ color var(--text)
113
+ &:after
114
+ opacity .5
115
+ img
116
+ width 48px
117
+ height 48px
118
+ object-fit cover
119
+
120
+ .link-title
121
+ font-weight bold
@@ -0,0 +1,12 @@
1
+ @import '_index'
2
+ @import '_article/other'
3
+ @import '_article/heading'
4
+ @import '_article/image'
5
+ @import '_article/table'
6
+ @import '_article/list'
7
+ @import '_article/footnote'
8
+ @import '_article/tabs'
9
+ @import '_article/note'
10
+ @import '_article/fold'
11
+ @import '_article/kbd'
12
+ @import '_article/links'
@@ -0,0 +1,4 @@
1
+ @import '_index'
2
+
3
+ .archive a
4
+ margin-left 1ch
@@ -0,0 +1,128 @@
1
+ import type { Temporal } from '@js-temporal/polyfill';
2
+ import type { ArrayOr } from 'ezal';
3
+ import type { TokenizeOptions } from 'ezal-markdown';
4
+ import type { RawTheme } from 'shiki';
5
+ export interface NavItem {
6
+ name: string;
7
+ link: string;
8
+ }
9
+ export interface Contact {
10
+ url: string;
11
+ name: string;
12
+ icon: string;
13
+ color: string;
14
+ }
15
+ export interface Link {
16
+ name: string;
17
+ description: string;
18
+ link: string;
19
+ avatar: string;
20
+ color: string;
21
+ }
22
+ export interface LinkGroup {
23
+ title: string;
24
+ description: string;
25
+ items: Link[];
26
+ }
27
+ export type LinkPageStyles = 'image' | 'table' | 'heading' | 'list' | 'footnote' | 'tabs' | 'note' | 'fold' | 'kbd';
28
+ export interface ThemeConfig {
29
+ /** 导航栏 */
30
+ nav?: NavItem[];
31
+ /** 站点图标 */
32
+ favicon?: ArrayOr<string>;
33
+ /** 主题色 */
34
+ color?: {
35
+ /** @default '#006000' */
36
+ light?: string;
37
+ /** @default '#00BB00' */
38
+ dark?: string;
39
+ };
40
+ /** 建站时间 */
41
+ since?: Temporal.ZonedDateTime;
42
+ /** 联系方式 */
43
+ contact?: Contact[];
44
+ /** 友情链接 */
45
+ links?: LinkGroup[];
46
+ /**
47
+ * 友情链接页面启用的样式
48
+ * @default 全部启用
49
+ */
50
+ linkPageStyles?: LinkPageStyles[];
51
+ /** Markdown 配置 */
52
+ markdown?: {
53
+ /**
54
+ * 换行规则
55
+ * @description
56
+ * - `common-mark`:CommonMark 规范,行尾 2+ 空格渲染为换行
57
+ * - `soft`:软换行,换行符 `\n` 渲染为换行
58
+ * @default `common-mark`
59
+ */
60
+ lineBreak?: TokenizeOptions['lineBreak'];
61
+ /**
62
+ * 代码块主题
63
+ * @default {light:'light-plus',dark:'dark-plus'}
64
+ */
65
+ codeBlockTheme?: {
66
+ light: RawTheme;
67
+ dark: RawTheme;
68
+ };
69
+ };
70
+ /** 主页设置 */
71
+ home?: {
72
+ /**
73
+ * 每页文章数量
74
+ * @default 10
75
+ */
76
+ articlesPrePage?: number;
77
+ logo?: {
78
+ viewBox: string;
79
+ g: string;
80
+ };
81
+ slogan?: string;
82
+ };
83
+ imageCache?: {
84
+ /**
85
+ * 图像元数据缓存路径
86
+ * @description
87
+ * 支持绝对路径和相对路径,相对路径将以工作目录为起点。
88
+ * 默认为工作目录下 `image-metadata.sqlite`。
89
+ */
90
+ metadata?: string;
91
+ /**
92
+ * 优化版图像缓存路径
93
+ * @description
94
+ * 支持绝对路径和相对路径,相对路径将以工作目录为起点。
95
+ * 默认为工作目录下 `cache`。
96
+ */
97
+ optimized?: string;
98
+ };
99
+ cdn?: {
100
+ /** @default 'https://unpkg.com/katex@0.16.21/dist/katex.min.css' */
101
+ katex?: string;
102
+ /** @default 'https://unpkg.com/@waline/client@v3/dist/waline.css' */
103
+ walineCSS?: string;
104
+ /** @default 'https://unpkg.com/@waline/client@v3/dist/waline.js' */
105
+ walineJS?: string;
106
+ };
107
+ /** HTML 头部插入内容 */
108
+ inject?: string;
109
+ /** IndexNow 配置 */
110
+ indexNow?: {
111
+ /** Bing IndexNow 密钥 */
112
+ bing?: string;
113
+ /** Yandex IndexNow 密钥 */
114
+ yandex?: string;
115
+ };
116
+ /** Waline 评论配置 */
117
+ waline?: {
118
+ /** 后端地址 */
119
+ serverURL: string;
120
+ visitor?: boolean;
121
+ commentCount?: boolean;
122
+ pageview?: boolean;
123
+ emoji?: string[];
124
+ reaction?: string[];
125
+ };
126
+ }
127
+ export declare function setThemeConfig(cfg?: ThemeConfig): void;
128
+ export declare function getThemeConfig(): ThemeConfig;
package/dist/feed.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { Article, Category } from 'ezal';
2
+ export declare function initFeed(): void;
3
+ export declare function updateFeedItem(article: Article): void;
4
+ export declare function updateFeedCategory(category: Category): void;
@@ -0,0 +1,22 @@
1
+ import { type Asset, VirtualAssets } from 'ezal';
2
+ import Sharp from 'sharp';
3
+ declare const OPTIMIZE: {
4
+ readonly '.avif': (sharp: Sharp.Sharp) => Promise<Buffer<ArrayBufferLike>>;
5
+ readonly '.webp': (sharp: Sharp.Sharp) => Promise<Buffer<ArrayBufferLike>>;
6
+ readonly '.jxl': (sharp: Sharp.Sharp) => Promise<Buffer<ArrayBufferLike>>;
7
+ readonly '.jpg': (sharp: Sharp.Sharp) => Promise<Buffer<ArrayBufferLike>>;
8
+ readonly '.png': (sharp: Sharp.Sharp) => Promise<Buffer<ArrayBufferLike>>;
9
+ readonly '.gif': (sharp: Sharp.Sharp) => Promise<Buffer<ArrayBufferLike>>;
10
+ };
11
+ export type OptimizedImageExt = keyof typeof OPTIMIZE;
12
+ export declare class OptimizedImage extends VirtualAssets {
13
+ #private;
14
+ /**
15
+ * @param asset 源资源
16
+ * @param target 目标优化格式
17
+ */
18
+ constructor(asset: Asset, ext: OptimizedImageExt);
19
+ build(): Promise<Buffer<ArrayBufferLike> | import("fs").ReadStream>;
20
+ protected onDependenciesChanged(): void;
21
+ }
22
+ export {};
@@ -0,0 +1,18 @@
1
+ export interface ImageMetadata {
2
+ path: string;
3
+ hash: string;
4
+ width: number;
5
+ height: number;
6
+ color: string | null;
7
+ }
8
+ declare function getMetadata(url: string): ImageMetadata | null;
9
+ declare function updateMetadata(data: ImageMetadata): boolean;
10
+ declare function deleteMetadata(url: string): boolean;
11
+ declare function initImageMetadataDB(): void;
12
+ export declare const imageDB: {
13
+ init: typeof initImageMetadataDB;
14
+ get: typeof getMetadata;
15
+ update: typeof updateMetadata;
16
+ delete: typeof deleteMetadata;
17
+ };
18
+ export {};
@@ -0,0 +1,10 @@
1
+ import { type Asset } from 'ezal';
2
+ import { type ImageMetadata } from './db';
3
+ export interface ImageInfo {
4
+ metadata: ImageMetadata | null;
5
+ rule?: string[];
6
+ }
7
+ export declare function getImageInfo(url: string): ImageInfo | null;
8
+ export declare function imageAddHook(asset: Asset): Promise<void>;
9
+ export declare function imageUpdateHook(asset: Asset): Promise<void>;
10
+ export declare function imageRemoveHook(asset: Asset): void;
@@ -0,0 +1,2 @@
1
+ import type { Asset } from 'ezal';
2
+ export declare function updateImageMetadata(asset: Asset): Promise<boolean>;
@@ -0,0 +1 @@
1
+ export declare function getOptimizedPath(filepath: string, ext: string): string;
@@ -0,0 +1 @@
1
+ export declare function exeIndexNow(): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { ThemeConfig as EzalThemeConfig } from 'ezal';
2
+ import { type ThemeConfig } from './config';
3
+ export declare function theme(config?: ThemeConfig): Promise<EzalThemeConfig>;