@xexr/blog-platform 1.0.13 → 1.0.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 796a777: Preserve higher-resolution article image previews when readers zoom inline images.
8
+
3
9
  ## 1.0.8
4
10
 
5
11
  ### Patch Changes
@@ -539,6 +539,7 @@ export default function ArticlePage({
539
539
  {(() => {
540
540
  const structuredDataProps = createStructuredDataScript(
541
541
  generateCompleteArticleStructuredData(article, {
542
+ customDomain: article.site.domain,
542
543
  pathPrefix: normalizedBasePath,
543
544
  }),
544
545
  );
@@ -17,6 +17,7 @@ export function ExpandableArticleImage({
17
17
  }
18
18
 
19
19
  const previewId = `blog-image-preview-${hashImageSrc(src)}`;
20
+ const previewSrc = getPreviewImageSrc(src);
20
21
 
21
22
  return (
22
23
  <>
@@ -50,7 +51,7 @@ export function ExpandableArticleImage({
50
51
  />
51
52
  <div className="pointer-events-none relative z-10 flex min-h-screen w-full items-center justify-center p-4 sm:p-6">
52
53
  <img
53
- src={src}
54
+ src={previewSrc}
54
55
  alt={alt}
55
56
  className="pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"
56
57
  />
@@ -67,6 +68,33 @@ export function ExpandableArticleImage({
67
68
  );
68
69
  }
69
70
 
71
+ export function getPreviewImageSrc(src: string): string {
72
+ if (!src.includes("/cdn-cgi/image/")) {
73
+ return src;
74
+ }
75
+
76
+ try {
77
+ const url = new URL(src);
78
+ const pathParts = url.pathname.split("/");
79
+ const imageIndex = pathParts.findIndex((part) => part === "image");
80
+
81
+ if (
82
+ imageIndex === -1 ||
83
+ pathParts[imageIndex - 1] !== "cdn-cgi" ||
84
+ !pathParts[imageIndex + 1]
85
+ ) {
86
+ return src;
87
+ }
88
+
89
+ pathParts[imageIndex + 1] = "width=1600,quality=90,format=webp";
90
+ url.pathname = pathParts.join("/");
91
+
92
+ return url.toString();
93
+ } catch {
94
+ return src;
95
+ }
96
+ }
97
+
70
98
  function hashImageSrc(src: string): string {
71
99
  let hash = 0;
72
100