@quintype/seo 1.49.2-fix-article-schema.0 → 1.49.3-article-image-array-schema.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.49.2](https://github.com/quintype/quintype-node-seo/compare/v1.49.1...v1.49.2) (2025-07-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * support article schema when enableNewsArticle is not set to "withoutArticleSchema" value ([#569](https://github.com/quintype/quintype-node-seo/issues/569)) ([bfacda1](https://github.com/quintype/quintype-node-seo/commit/bfacda161f4d9b2e5d220acb1c3088081c0f04ec))
11
+
5
12
  ### [1.49.1](https://github.com/quintype/quintype-node-seo/compare/v1.49.1-live-blog-meta-description.1...v1.49.1) (2025-07-01)
6
13
 
7
14
 
package/dist/index.cjs.js CHANGED
@@ -680,10 +680,40 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
680
680
  dateModified: stripMillisecondsFromTime(new Date(story["last-published-at"]), timezone),
681
681
  datePublished: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
682
682
  name: storyKeysPresence && story.headline || "",
683
- image: generateArticleImageData(story["hero-image-s3-key"], publisherConfig)
683
+ image: generateArticleHeroImageData(story["hero-image-s3-key"], publisherConfig, story["hero-image-metadata"])
684
684
  }, isAccessibleForFree, sponsor, { isPartOf: generateIsPartOfDataForArticle(story, publisherConfig) }, articleSectionObj(story));
685
685
  }
686
686
 
687
+ function generateArticleHeroImageData(image, publisherConfig = {}, imageMetadata = {}) {
688
+ const imageWidth = 1200;
689
+ const imageHeights = [675, 900, 1200];
690
+ const hasMetadata = imageMetadata && Object.keys(imageMetadata).length > 0;
691
+
692
+ const focusedImage = hasMetadata ? new quintypeJs.FocusedImage(image, imageMetadata) : null;
693
+
694
+ return imageHeights.map(height => {
695
+ let croppedImage = "";
696
+ const imageSrc = /^https?.*/.test(publisherConfig["cdn-image"]) ? publisherConfig["cdn-image"] : `https://${publisherConfig["cdn-image"]}`;
697
+
698
+ if (focusedImage) {
699
+ const path = focusedImage.path([imageWidth, height], {
700
+ w: imageWidth,
701
+ h: height,
702
+ auto: "format,compress",
703
+ fit: "crop"
704
+ });
705
+ path.split("?");
706
+ const rectPropsImage = decodeURIComponent(path);
707
+ croppedImage = `${imageSrc}/${rectPropsImage}`;
708
+ }
709
+ const finalUrl = focusedImage ? croppedImage : imageUrl(publisherConfig, image, imageWidth, height);
710
+ return Object.assign({
711
+ "@type": "ImageObject",
712
+ url: finalUrl
713
+ }, getQueryParams(finalUrl));
714
+ });
715
+ }
716
+
687
717
  function generateArticleImageData(image, publisherConfig = {}) {
688
718
  const imageWidth = 1200;
689
719
  const imageHeight = 675;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.49.2-fix-article-schema.0",
3
+ "version": "1.49.3-article-image-array-schema.0",
4
4
  "description": "SEO Modules for Quintype",
5
5
  "main": "dist/index.cjs.js",
6
6
  "repository": "https://github.com/quintype/quintype-node-seo",
@@ -1,4 +1,5 @@
1
1
  import get from "lodash/get";
2
+ import { FocusedImage } from "quintype-js";
2
3
  import { getAllowedCards, getQueryParams, stripMillisecondsFromTime, stripQueryParams } from "../utils";
3
4
  import { generateTagsForEntity } from "./entity";
4
5
  import {
@@ -122,7 +123,7 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
122
123
  dateModified: stripMillisecondsFromTime(new Date(story["last-published-at"]), timezone),
123
124
  datePublished: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
124
125
  name: (storyKeysPresence && story.headline) || "",
125
- image: generateArticleImageData(story["hero-image-s3-key"], publisherConfig),
126
+ image: generateArticleHeroImageData(story["hero-image-s3-key"], publisherConfig, story["hero-image-metadata"]),
126
127
  },
127
128
  isAccessibleForFree,
128
129
  sponsor,
@@ -131,6 +132,41 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
131
132
  );
132
133
  }
133
134
 
135
+ function generateArticleHeroImageData(image, publisherConfig = {}, imageMetadata = {}) {
136
+ const imageWidth = 1200;
137
+ const imageHeights = [675, 900, 1200];
138
+ const hasMetadata = imageMetadata && Object.keys(imageMetadata).length > 0;
139
+
140
+ const focusedImage = hasMetadata ? new FocusedImage(image, imageMetadata) : null;
141
+
142
+ return imageHeights.map((height) => {
143
+ let croppedImage = "";
144
+ const imageSrc = /^https?.*/.test(publisherConfig["cdn-image"])
145
+ ? publisherConfig["cdn-image"]
146
+ : `https://${publisherConfig["cdn-image"]}`;
147
+
148
+ if (focusedImage) {
149
+ const path = focusedImage.path([imageWidth, height], {
150
+ w: imageWidth,
151
+ h: height,
152
+ auto: "format,compress",
153
+ fit: "crop",
154
+ });
155
+ const [encodedSlug] = path.split("?");
156
+ const rectPropsImage = decodeURIComponent(path);
157
+ croppedImage = `${imageSrc}/${rectPropsImage}`;
158
+ }
159
+ const finalUrl = focusedImage ? croppedImage : imageUrl(publisherConfig, image, imageWidth, height);
160
+ return Object.assign(
161
+ {
162
+ "@type": "ImageObject",
163
+ url: finalUrl,
164
+ },
165
+ getQueryParams(finalUrl)
166
+ );
167
+ });
168
+ }
169
+
134
170
  function generateArticleImageData(image, publisherConfig = {}) {
135
171
  const imageWidth = 1200;
136
172
  const imageHeight = 675;