@laioutr/app-hygraph 1.6.0 → 1.6.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.
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laioutr/app-hygraph",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "configKey": "@laioutr/app-hygraph",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import { defu } from 'defu';
3
3
  import { registerLaioutrApp } from '@laioutr-core/kit';
4
4
 
5
5
  const name = "@laioutr/app-hygraph";
6
- const version = "1.6.0";
6
+ const version = "1.6.1";
7
7
 
8
8
  const module = defineNuxtModule({
9
9
  meta: {
@@ -1,4 +1,4 @@
1
- import { MediaImage } from '@laioutr-core/core-types/common';
1
+ import { Media } from '@laioutr-core/core-types/common';
2
2
  import type { HygraphAsset } from '../types/hygraph.js';
3
3
  /** Remove the file extension from a file name. */
4
4
  export declare const stripFileExtension: (fileName: string) => string;
@@ -7,4 +7,4 @@ export declare const filenameToAlt: (fileName: string) => string;
7
7
  /**
8
8
  * Map a Hygraph asset to a Media object.
9
9
  */
10
- export declare const mapHygraphMedia: (asset: HygraphAsset) => MediaImage;
10
+ export declare const mapHygraphMedia: (asset: HygraphAsset) => Media;
@@ -1,16 +1,34 @@
1
1
  export const stripFileExtension = (fileName) => fileName.replace(/\.[^.]+$/, "");
2
2
  export const filenameToAlt = (fileName) => stripFileExtension(fileName).replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").replace(/^\w/, (c) => c.toUpperCase()).trim();
3
- export const mapHygraphMedia = (asset) => ({
4
- type: "image",
5
- sources: [
6
- {
7
- // SVGs are returned as none so Nuxt Image won't turn them into PNG file links.
8
- provider: asset.mimeType === "image/svg+xml" ? "none" : "hygraph",
9
- src: asset.url,
10
- width: asset.width ?? void 0,
11
- height: asset.height ?? void 0,
12
- responsive: "static"
13
- }
14
- ],
15
- alt: filenameToAlt(asset.fileName)
16
- });
3
+ export const mapHygraphMedia = (asset) => {
4
+ const mimeType = typeof asset.mimeType === "string" ? asset.mimeType : "";
5
+ if (mimeType.startsWith("video/")) {
6
+ return {
7
+ type: "video",
8
+ sources: [
9
+ {
10
+ provider: "hygraph",
11
+ src: asset.url,
12
+ width: asset.width ?? void 0,
13
+ height: asset.height ?? void 0,
14
+ format: mimeType.slice("video/".length)
15
+ }
16
+ ],
17
+ alt: filenameToAlt(asset.fileName)
18
+ };
19
+ }
20
+ return {
21
+ type: "image",
22
+ sources: [
23
+ {
24
+ // SVGs are returned as none so Nuxt Image won't turn them into PNG file links.
25
+ provider: mimeType === "image/svg+xml" ? "none" : "hygraph",
26
+ src: asset.url,
27
+ width: asset.width ?? void 0,
28
+ height: asset.height ?? void 0,
29
+ responsive: "static"
30
+ }
31
+ ],
32
+ alt: filenameToAlt(asset.fileName)
33
+ };
34
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laioutr/app-hygraph",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Laioutr Hygraph App",
5
5
  "repository": "your-org/@laioutr/app-hygraph",
6
6
  "license": "MIT",