hexo-theme-linen 1.0.35 → 1.0.37

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": "hexo-theme-linen",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "A clean Hexo theme",
5
5
  "main": "index.js",
6
6
  "homepage": "https://github.com/lynanbreeze/hexo-theme-linen",
@@ -78,7 +78,7 @@ hexo.extend.filter.register("before_post_render", function (data) {
78
78
 
79
79
  const backrefs = Array.from({ length: refCount[id] || 0 }, (_, i) => {
80
80
  const n = i + 1;
81
- return `<a href="#fnref-${id}-${n}" class="footnote-backref"></a>`;
81
+ return `<a href="#fnref-${id}-${n}" class="footnote-backref" aria-label="返回脚注引用" title="返回脚注引用"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M20 6v5a3 3 0 0 1-3 3H4m0 0 4-4m-4 4 4 4" /></svg></a>`;
82
82
  }).join(" ");
83
83
 
84
84
  return `<li id="fn-${id}">${html}${backrefs}</li>`;
@@ -1,10 +1,10 @@
1
1
  module.exports.defaultConfig = {
2
2
  enable: false,
3
- loadingImage: "../linen-theme/img/lazyload/loading.svg",
4
- errorTipImage: "../linen-theme/img/lazyload/error-tip.svg",
3
+ loadingImage: "/linen-theme/img/lazyload/loading.svg",
4
+ errorTipImage: "/linen-theme/img/lazyload/error-tip.svg",
5
5
  intersectionRatio: 0.25,
6
6
  placeholderRatio: 3 / 2,
7
7
  showTransition: true,
8
8
  showAltText: true,
9
9
  preloadCount: 5
10
- }
10
+ }
@@ -19,11 +19,27 @@ module.exports = function (hexo) {
19
19
  ...(hexo?.config?.theme_config?.lazyload || {}),
20
20
  };
21
21
 
22
+ const resolveSiteAsset = (assetPath) => {
23
+ if (!assetPath || /^(https?:)?\/\//i.test(assetPath) || /^data:/i.test(assetPath)) {
24
+ return assetPath;
25
+ }
26
+ if (!assetPath.startsWith("/")) return assetPath;
27
+
28
+ const rootSegments = String(hexo.config.root || "")
29
+ .split("/")
30
+ .filter(Boolean)
31
+ .join("/");
32
+ const root = rootSegments ? `/${rootSegments}/` : "/";
33
+ return `${root}${assetPath.replace(/^\/+/, "")}`;
34
+ };
35
+ const resolvedLoadingImage = resolveSiteAsset(loadingImage);
36
+ const resolvedErrorTipImage = resolveSiteAsset(errorTipImage);
37
+
22
38
  const placeholderImage =
23
- /^(https?:\/\/|\/|data:image|\.\.\/)/i.test(loadingImage) ||
24
- /\.(svg|png|jpg|jpeg|webp|gif)$/i.test(loadingImage)
25
- ? `url(${loadingImage})`
26
- : loadingImage;
39
+ /^(https?:\/\/|\/|data:image|\.\.\/)/i.test(resolvedLoadingImage) ||
40
+ /\.(svg|png|jpg|jpeg|webp|gif)$/i.test(resolvedLoadingImage)
41
+ ? `url(${resolvedLoadingImage})`
42
+ : resolvedLoadingImage;
27
43
 
28
44
  const injectedStyles = `.lazyload-outer-wrap .caption{
29
45
  width: 100%;
@@ -47,7 +63,7 @@ module.exports = function (hexo) {
47
63
  padding-bottom: ${(100 / Number(placeholderRatio)).toFixed(5)}%;
48
64
  background-size: 100% 100%;
49
65
  background-repeat: no-repeat;
50
- ${loadingImage ? `background-image: ${placeholderImage};` : ""}
66
+ ${resolvedLoadingImage ? `background-image: ${placeholderImage};` : ""}
51
67
  background-color: #fff;
52
68
  }
53
69
  .lazyload-wrap .placeholder canvas{
@@ -104,7 +120,7 @@ module.exports = function (hexo) {
104
120
  .lazyload-wrap .error-wrap .error-tip{
105
121
  width: 60%;
106
122
  background-size: cover;
107
- background-image: url(${errorTipImage});
123
+ background-image: url(${resolvedErrorTipImage});
108
124
  }
109
125
  .lazyload-wrap .error-wrap .error-tip::before{
110
126
  content: '';
@@ -166,11 +182,11 @@ module.exports = function (hexo) {
166
182
  if (/<\/body>/gi.test(htmlContent)) {
167
183
  htmlContent = appendToHead(settingsContent, htmlContent);
168
184
  htmlContent = appendToHead(
169
- `<link rel="preload" as="image" href="${loadingImage}" />`,
185
+ `<link rel="preload" as="image" href="${resolvedLoadingImage}" />`,
170
186
  htmlContent,
171
187
  );
172
188
  htmlContent = appendToHead(
173
- `<link rel="preload" as="image" href="${errorTipImage}" />`,
189
+ `<link rel="preload" as="image" href="${resolvedErrorTipImage}" />`,
174
190
  htmlContent,
175
191
  );
176
192
  injectExtraScript(lazyLoadPath);
@@ -20,7 +20,7 @@
20
20
  padding-bottom: 66.66667%;
21
21
  background-size: 100% 100%;
22
22
  background-repeat: no-repeat;
23
- background-image: url(../linen-theme/img/lazyload/loading.svg);
23
+ background-image: url(/linen-theme/img/lazyload/loading.svg);
24
24
  background-color: #fff;
25
25
  }
26
26
  .lazyload-wrap .placeholder canvas{
@@ -77,7 +77,7 @@
77
77
  .lazyload-wrap .error-wrap .error-tip{
78
78
  width: 60%;
79
79
  background-size: cover;
80
- background-image: url(../linen-theme/img/lazyload/error-tip.svg);
80
+ background-image: url(/linen-theme/img/lazyload/error-tip.svg);
81
81
  }
82
82
  .lazyload-wrap .error-wrap .error-tip::before{
83
83
  content: '';
@@ -651,6 +651,12 @@ body {
651
651
  vertical-align: middle;
652
652
  margin-bottom: 0.25em;
653
653
  }
654
+ &:empty::after {
655
+ display: none;
656
+ }
657
+ &:has(img)::after {
658
+ display: none;
659
+ }
654
660
  &:hover {
655
661
  opacity: 0.85;
656
662
  border-bottom: solid 1px $green;
@@ -679,6 +685,32 @@ body {
679
685
  }
680
686
  }
681
687
 
688
+ .footnote-anchor-wrap {
689
+ scroll-margin-top: 1.5em;
690
+ }
691
+
692
+ .footnotes .footnote-backref {
693
+ display: inline-block;
694
+ margin-left: 0.35em;
695
+ font-weight: normal;
696
+
697
+ svg {
698
+ display: inline-block;
699
+ width: 1em;
700
+ height: 1em;
701
+ overflow: visible;
702
+ vertical-align: -0.16em;
703
+ }
704
+
705
+ path {
706
+ fill: none;
707
+ stroke: currentColor;
708
+ stroke-linecap: round;
709
+ stroke-linejoin: round;
710
+ stroke-width: 2;
711
+ }
712
+ }
713
+
682
714
  del {
683
715
  a:not([class]):not(:has(.shared-link)) {
684
716
  &::after {