@okam/directus-next-component 1.5.0 → 1.6.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/components/DirectusFile/interface.d.ts +1 -1
- package/directus/directus-next-component/src/hooks/directus-metadata.js +92 -0
- package/directus/directus-next-component/src/hooks/directus-metadata.mjs +93 -0
- package/directus/directus-next-component/src/index.js +2 -0
- package/directus/directus-next-component/src/index.mjs +2 -0
- package/directus/directus-next-component/src/server.js +2 -0
- package/directus/directus-next-component/src/server.mjs +2 -0
- package/hooks/directus-file.d.ts +1 -1
- package/hooks/directus-metadata.d.ts +6 -0
- package/index.d.ts +11 -2
- package/package.json +21 -8
- package/server.d.ts +1 -0
- package/types/links.d.ts +1 -2
- package/types/metadata.d.ts +60 -0
- package/types/files.d.ts +0 -24
- package/types/page-settings.d.ts +0 -17
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { TFiles } from '@okam/directus-next';
|
|
1
2
|
import type { TDefaultComponent } from '@okam/stack-ui';
|
|
2
|
-
import type { TFiles } from '../../types/files';
|
|
3
3
|
export interface TDirectusFileProps extends TFiles, TDefaultComponent {
|
|
4
4
|
/**
|
|
5
5
|
* Serves to fall back to different parts of the URLs. Some properties have default values:
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require("react/jsx-runtime");
|
|
3
|
+
require("@okam/next-component");
|
|
4
|
+
const directusFile = require("./directus-file.js");
|
|
5
|
+
require("@okam/stack-ui");
|
|
6
|
+
require("next/link.js");
|
|
7
|
+
require("../logger.js");
|
|
8
|
+
const radashi = require("radashi");
|
|
9
|
+
function withFallbacks(pageProps, options) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const { pageSettings } = pageProps ?? {};
|
|
12
|
+
const pageSettingsTranslation = (_a = pageSettings == null ? void 0 : pageSettings.translations) == null ? void 0 : _a[0];
|
|
13
|
+
const itemTranslation = (_b = pageSettings == null ? void 0 : pageSettings.translations) == null ? void 0 : _b[0];
|
|
14
|
+
const title = (pageSettingsTranslation == null ? void 0 : pageSettingsTranslation.title) ?? (itemTranslation == null ? void 0 : itemTranslation.title);
|
|
15
|
+
const imageFragment = (pageSettingsTranslation == null ? void 0 : pageSettingsTranslation.og_image) ?? (itemTranslation && "featured_image" in itemTranslation ? itemTranslation.featured_image : {});
|
|
16
|
+
const image = options.getFilesFragment(imageFragment);
|
|
17
|
+
return { title, image };
|
|
18
|
+
}
|
|
19
|
+
function limitOpenGraphImageDimensions(width, height, maxWidth, maxHeight) {
|
|
20
|
+
return {
|
|
21
|
+
width: radashi.min([parseInt(width.toString(), 10), maxWidth]),
|
|
22
|
+
height: radashi.min([parseInt(height.toString(), 10), maxHeight])
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getOpenGraphImageFallback(fallbackImage, options) {
|
|
26
|
+
if (!fallbackImage) return null;
|
|
27
|
+
const { width, height, src } = fallbackImage;
|
|
28
|
+
const dimensions = limitOpenGraphImageDimensions(width, height, options == null ? void 0 : options.ogImageMaxWidth, options == null ? void 0 : options.ogImageMaxHeight);
|
|
29
|
+
return { ...fallbackImage, ...dimensions, url: src };
|
|
30
|
+
}
|
|
31
|
+
function useOpenGraphImage(image, options) {
|
|
32
|
+
const directusImage = directusFile(image);
|
|
33
|
+
const { src, alt } = directusImage ?? {};
|
|
34
|
+
const { width: limitedWidth, height: limitedHeight } = ((directusImage == null ? void 0 : directusImage.width) && (directusImage == null ? void 0 : directusImage.height) ? limitOpenGraphImageDimensions(
|
|
35
|
+
directusImage.width,
|
|
36
|
+
directusImage.height,
|
|
37
|
+
options == null ? void 0 : options.ogImageMaxWidth,
|
|
38
|
+
options == null ? void 0 : options.ogImageMaxHeight
|
|
39
|
+
) : null) ?? {};
|
|
40
|
+
if (!src || !(directusImage == null ? void 0 : directusImage.width)) return null;
|
|
41
|
+
const imgHref = options == null ? void 0 : options.imageLoader({
|
|
42
|
+
...image,
|
|
43
|
+
src,
|
|
44
|
+
width: limitedWidth,
|
|
45
|
+
height: limitedHeight ?? void 0
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
alt,
|
|
49
|
+
type: (directusImage == null ? void 0 : directusImage.type) ?? void 0,
|
|
50
|
+
width: limitedWidth,
|
|
51
|
+
height: limitedHeight,
|
|
52
|
+
url: imgHref
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function useMetadata(pageProps, options, defaultProps) {
|
|
56
|
+
var _a;
|
|
57
|
+
const { title, image } = withFallbacks(pageProps, options);
|
|
58
|
+
const { pageSettings } = pageProps ?? {};
|
|
59
|
+
const translation = (_a = pageSettings == null ? void 0 : pageSettings.translations) == null ? void 0 : _a[0];
|
|
60
|
+
const metaDescription = (defaultProps == null ? void 0 : defaultProps.meta_description) ?? (translation == null ? void 0 : translation.meta_description);
|
|
61
|
+
const noFollow = (defaultProps == null ? void 0 : defaultProps.no_follow) ?? (translation == null ? void 0 : translation.no_follow);
|
|
62
|
+
const noIndex = (defaultProps == null ? void 0 : defaultProps.no_index) ?? (translation == null ? void 0 : translation.no_index);
|
|
63
|
+
const directusImage = directusFile(image);
|
|
64
|
+
const openGraphImage = useOpenGraphImage(directusImage, options) ?? getOpenGraphImageFallback(options == null ? void 0 : options.ogFallbackImage, options);
|
|
65
|
+
const openGraphType = options.openGraphTypeConfig[(pageSettings == null ? void 0 : pageSettings.belongs_to_collection) ?? ""] ?? "website";
|
|
66
|
+
const alternates = options.createAlternateUrls(pageSettings);
|
|
67
|
+
const { canonical } = alternates;
|
|
68
|
+
const metadata = {
|
|
69
|
+
title,
|
|
70
|
+
metadataBase: URL.canParse(options.getHostname()) ? new URL(options.getHostname()) : void 0,
|
|
71
|
+
description: metaDescription,
|
|
72
|
+
openGraph: {
|
|
73
|
+
title: title ?? void 0,
|
|
74
|
+
description: metaDescription ?? void 0,
|
|
75
|
+
images: openGraphImage ?? void 0,
|
|
76
|
+
url: canonical == null ? void 0 : canonical.toString(),
|
|
77
|
+
type: openGraphType
|
|
78
|
+
},
|
|
79
|
+
twitter: {
|
|
80
|
+
title: title ?? void 0,
|
|
81
|
+
images: openGraphImage ?? void 0,
|
|
82
|
+
description: metaDescription ?? void 0
|
|
83
|
+
},
|
|
84
|
+
alternates,
|
|
85
|
+
robots: {
|
|
86
|
+
index: !noIndex,
|
|
87
|
+
follow: !noFollow
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return metadata;
|
|
91
|
+
}
|
|
92
|
+
module.exports = useMetadata;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "@okam/next-component";
|
|
3
|
+
import useDirectusFile from "./directus-file.mjs";
|
|
4
|
+
import "@okam/stack-ui";
|
|
5
|
+
import "next/link.js";
|
|
6
|
+
import "../logger.mjs";
|
|
7
|
+
import { min } from "radashi";
|
|
8
|
+
function withFallbacks(pageProps, options) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const { pageSettings } = pageProps ?? {};
|
|
11
|
+
const pageSettingsTranslation = (_a = pageSettings == null ? void 0 : pageSettings.translations) == null ? void 0 : _a[0];
|
|
12
|
+
const itemTranslation = (_b = pageSettings == null ? void 0 : pageSettings.translations) == null ? void 0 : _b[0];
|
|
13
|
+
const title = (pageSettingsTranslation == null ? void 0 : pageSettingsTranslation.title) ?? (itemTranslation == null ? void 0 : itemTranslation.title);
|
|
14
|
+
const imageFragment = (pageSettingsTranslation == null ? void 0 : pageSettingsTranslation.og_image) ?? (itemTranslation && "featured_image" in itemTranslation ? itemTranslation.featured_image : {});
|
|
15
|
+
const image = options.getFilesFragment(imageFragment);
|
|
16
|
+
return { title, image };
|
|
17
|
+
}
|
|
18
|
+
function limitOpenGraphImageDimensions(width, height, maxWidth, maxHeight) {
|
|
19
|
+
return {
|
|
20
|
+
width: min([parseInt(width.toString(), 10), maxWidth]),
|
|
21
|
+
height: min([parseInt(height.toString(), 10), maxHeight])
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getOpenGraphImageFallback(fallbackImage, options) {
|
|
25
|
+
if (!fallbackImage) return null;
|
|
26
|
+
const { width, height, src } = fallbackImage;
|
|
27
|
+
const dimensions = limitOpenGraphImageDimensions(width, height, options == null ? void 0 : options.ogImageMaxWidth, options == null ? void 0 : options.ogImageMaxHeight);
|
|
28
|
+
return { ...fallbackImage, ...dimensions, url: src };
|
|
29
|
+
}
|
|
30
|
+
function useOpenGraphImage(image, options) {
|
|
31
|
+
const directusImage = useDirectusFile(image);
|
|
32
|
+
const { src, alt } = directusImage ?? {};
|
|
33
|
+
const { width: limitedWidth, height: limitedHeight } = ((directusImage == null ? void 0 : directusImage.width) && (directusImage == null ? void 0 : directusImage.height) ? limitOpenGraphImageDimensions(
|
|
34
|
+
directusImage.width,
|
|
35
|
+
directusImage.height,
|
|
36
|
+
options == null ? void 0 : options.ogImageMaxWidth,
|
|
37
|
+
options == null ? void 0 : options.ogImageMaxHeight
|
|
38
|
+
) : null) ?? {};
|
|
39
|
+
if (!src || !(directusImage == null ? void 0 : directusImage.width)) return null;
|
|
40
|
+
const imgHref = options == null ? void 0 : options.imageLoader({
|
|
41
|
+
...image,
|
|
42
|
+
src,
|
|
43
|
+
width: limitedWidth,
|
|
44
|
+
height: limitedHeight ?? void 0
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
alt,
|
|
48
|
+
type: (directusImage == null ? void 0 : directusImage.type) ?? void 0,
|
|
49
|
+
width: limitedWidth,
|
|
50
|
+
height: limitedHeight,
|
|
51
|
+
url: imgHref
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function useMetadata(pageProps, options, defaultProps) {
|
|
55
|
+
var _a;
|
|
56
|
+
const { title, image } = withFallbacks(pageProps, options);
|
|
57
|
+
const { pageSettings } = pageProps ?? {};
|
|
58
|
+
const translation = (_a = pageSettings == null ? void 0 : pageSettings.translations) == null ? void 0 : _a[0];
|
|
59
|
+
const metaDescription = (defaultProps == null ? void 0 : defaultProps.meta_description) ?? (translation == null ? void 0 : translation.meta_description);
|
|
60
|
+
const noFollow = (defaultProps == null ? void 0 : defaultProps.no_follow) ?? (translation == null ? void 0 : translation.no_follow);
|
|
61
|
+
const noIndex = (defaultProps == null ? void 0 : defaultProps.no_index) ?? (translation == null ? void 0 : translation.no_index);
|
|
62
|
+
const directusImage = useDirectusFile(image);
|
|
63
|
+
const openGraphImage = useOpenGraphImage(directusImage, options) ?? getOpenGraphImageFallback(options == null ? void 0 : options.ogFallbackImage, options);
|
|
64
|
+
const openGraphType = options.openGraphTypeConfig[(pageSettings == null ? void 0 : pageSettings.belongs_to_collection) ?? ""] ?? "website";
|
|
65
|
+
const alternates = options.createAlternateUrls(pageSettings);
|
|
66
|
+
const { canonical } = alternates;
|
|
67
|
+
const metadata = {
|
|
68
|
+
title,
|
|
69
|
+
metadataBase: URL.canParse(options.getHostname()) ? new URL(options.getHostname()) : void 0,
|
|
70
|
+
description: metaDescription,
|
|
71
|
+
openGraph: {
|
|
72
|
+
title: title ?? void 0,
|
|
73
|
+
description: metaDescription ?? void 0,
|
|
74
|
+
images: openGraphImage ?? void 0,
|
|
75
|
+
url: canonical == null ? void 0 : canonical.toString(),
|
|
76
|
+
type: openGraphType
|
|
77
|
+
},
|
|
78
|
+
twitter: {
|
|
79
|
+
title: title ?? void 0,
|
|
80
|
+
images: openGraphImage ?? void 0,
|
|
81
|
+
description: metaDescription ?? void 0
|
|
82
|
+
},
|
|
83
|
+
alternates,
|
|
84
|
+
robots: {
|
|
85
|
+
index: !noIndex,
|
|
86
|
+
follow: !noFollow
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return metadata;
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
useMetadata as default
|
|
93
|
+
};
|
|
@@ -7,6 +7,7 @@ const index$3 = require("./components/DirectusFile/index.js");
|
|
|
7
7
|
const directusFile = require("./hooks/directus-file.js");
|
|
8
8
|
const directusLink = require("./hooks/directus-link.js");
|
|
9
9
|
const navigationItems = require("./hooks/navigation-items.js");
|
|
10
|
+
const directusMetadata = require("./hooks/directus-metadata.js");
|
|
10
11
|
const logger = require("./logger.js");
|
|
11
12
|
exports.DirectusLink = index;
|
|
12
13
|
exports.DirectusImg = index$1;
|
|
@@ -15,4 +16,5 @@ exports.DirectusFile = index$3;
|
|
|
15
16
|
exports.useDirectusFile = directusFile;
|
|
16
17
|
exports.useDirectusLink = directusLink;
|
|
17
18
|
exports.useNavigationItems = navigationItems;
|
|
19
|
+
exports.useMetadata = directusMetadata;
|
|
18
20
|
exports.DirectusNextComponent = logger.logger;
|
|
@@ -5,6 +5,7 @@ import { default as default5 } from "./components/DirectusFile/index.mjs";
|
|
|
5
5
|
import { default as default6 } from "./hooks/directus-file.mjs";
|
|
6
6
|
import { default as default7 } from "./hooks/directus-link.mjs";
|
|
7
7
|
import { default as default8 } from "./hooks/navigation-items.mjs";
|
|
8
|
+
import { default as default9 } from "./hooks/directus-metadata.mjs";
|
|
8
9
|
import { logger } from "./logger.mjs";
|
|
9
10
|
export {
|
|
10
11
|
default5 as DirectusFile,
|
|
@@ -14,5 +15,6 @@ export {
|
|
|
14
15
|
default4 as DirectusVideo,
|
|
15
16
|
default6 as useDirectusFile,
|
|
16
17
|
default7 as useDirectusLink,
|
|
18
|
+
default9 as useMetadata,
|
|
17
19
|
default8 as useNavigationItems
|
|
18
20
|
};
|
|
@@ -9,6 +9,7 @@ const logger = require("./logger.js");
|
|
|
9
9
|
const directusFile = require("./hooks/directus-file.js");
|
|
10
10
|
const directusLink = require("./hooks/directus-link.js");
|
|
11
11
|
const navigationItems = require("./hooks/navigation-items.js");
|
|
12
|
+
const directusMetadata = require("./hooks/directus-metadata.js");
|
|
12
13
|
exports.withDirectus = withDirectus;
|
|
13
14
|
exports.DirectusFile = index;
|
|
14
15
|
exports.DirectusImg = index$1;
|
|
@@ -18,3 +19,4 @@ exports.DirectusNextComponent = logger.logger;
|
|
|
18
19
|
exports.useDirectusFile = directusFile;
|
|
19
20
|
exports.useDirectusLink = directusLink;
|
|
20
21
|
exports.useNavigationItems = navigationItems;
|
|
22
|
+
exports.useMetadata = directusMetadata;
|
|
@@ -7,6 +7,7 @@ import { logger } from "./logger.mjs";
|
|
|
7
7
|
import { default as default7 } from "./hooks/directus-file.mjs";
|
|
8
8
|
import { default as default8 } from "./hooks/directus-link.mjs";
|
|
9
9
|
import { default as default9 } from "./hooks/navigation-items.mjs";
|
|
10
|
+
import { default as default10 } from "./hooks/directus-metadata.mjs";
|
|
10
11
|
export {
|
|
11
12
|
default3 as DirectusFile,
|
|
12
13
|
default4 as DirectusImg,
|
|
@@ -15,6 +16,7 @@ export {
|
|
|
15
16
|
default6 as DirectusVideo,
|
|
16
17
|
default7 as useDirectusFile,
|
|
17
18
|
default8 as useDirectusLink,
|
|
19
|
+
default10 as useMetadata,
|
|
18
20
|
default9 as useNavigationItems,
|
|
19
21
|
default2 as withDirectus
|
|
20
22
|
};
|
package/hooks/directus-file.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { TFiles } from '@okam/directus-next';
|
|
1
2
|
import type { Nullable } from '@okam/stack-ui';
|
|
2
|
-
import type { TFiles } from '../types/files';
|
|
3
3
|
export default function useDirectusFile(file: Nullable<TFiles>, baseUrl?: URL, searchParams?: Record<string, Nullable<string>>): {
|
|
4
4
|
tags?: any;
|
|
5
5
|
location?: string | null | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TPageSettings, TPageSettingsTranslation } from '@okam/directus-next';
|
|
2
|
+
import type { Metadata } from 'next';
|
|
3
|
+
import type { TMetadataOptions } from '../types/metadata';
|
|
4
|
+
export default function useMetadata<TPageProps extends {
|
|
5
|
+
pageSettings: TPageSettings;
|
|
6
|
+
}>(pageProps: TPageProps, options: TMetadataOptions, defaultProps?: Partial<TPageSettingsTranslation>): Metadata;
|
package/index.d.ts
CHANGED
|
@@ -5,9 +5,18 @@ export { default as DirectusFile } from './components/DirectusFile';
|
|
|
5
5
|
export { default as useDirectusFile } from './hooks/directus-file';
|
|
6
6
|
export { default as useDirectusLink } from './hooks/directus-link';
|
|
7
7
|
export { default as useNavigationItems } from './hooks/navigation-items';
|
|
8
|
+
export { default as useMetadata } from './hooks/directus-metadata';
|
|
8
9
|
export { logger as DirectusNextComponent } from './logger';
|
|
9
|
-
export type {
|
|
10
|
-
|
|
10
|
+
export type {
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Import from `@okam/directus-next` instead
|
|
13
|
+
*/
|
|
14
|
+
TFiles, } from '@okam/directus-next';
|
|
15
|
+
export type {
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Import from `@okam/directus-next` instead
|
|
18
|
+
*/ TPageSettings, } from '@okam/directus-next';
|
|
11
19
|
export type { TNavigationItems, TNavigationItemsTree } from './types/navigation-items';
|
|
12
20
|
export type { TLinks } from './types/links';
|
|
13
21
|
export type { TDirectusLinkProps, TUseDirectusLink, TDirectusLink, TDirectusLinkPropsConfig, TDirectusLinkComponentsConfig, } from './components/DirectusLink/interface';
|
|
22
|
+
export type { TMetadataOptions } from './types/metadata';
|
package/package.json
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okam/directus-next-component",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"import":
|
|
9
|
-
|
|
8
|
+
"import": {
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"default": "./index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"require": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"default": "./index.mjs"
|
|
15
|
+
}
|
|
10
16
|
},
|
|
11
17
|
"./server": {
|
|
12
|
-
"import":
|
|
13
|
-
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./server.d.ts",
|
|
20
|
+
"default": "./server.mjs"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./server.d.ts",
|
|
24
|
+
"default": "./server.mjs"
|
|
25
|
+
}
|
|
14
26
|
}
|
|
15
27
|
},
|
|
16
28
|
"publishConfig": {
|
|
@@ -21,12 +33,13 @@
|
|
|
21
33
|
},
|
|
22
34
|
"dependencies": {
|
|
23
35
|
"@okam/logger": "1.1.0",
|
|
24
|
-
"@okam/next-component": "0.
|
|
25
|
-
"@okam/stack-ui": "1.
|
|
36
|
+
"@okam/next-component": "1.0.0",
|
|
37
|
+
"@okam/stack-ui": "1.34.0",
|
|
26
38
|
"@react-spring/web": "^9.7.5",
|
|
27
39
|
"next": "^14.1.1",
|
|
28
40
|
"radashi": "^12.3.0",
|
|
29
41
|
"react": "18.3.1",
|
|
30
|
-
"unlazy": "^0.12.1"
|
|
42
|
+
"unlazy": "^0.12.1",
|
|
43
|
+
"@okam/directus-next": "1.1.0"
|
|
31
44
|
}
|
|
32
45
|
}
|
package/server.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { logger as DirectusNextComponent } from './logger';
|
|
|
7
7
|
export { default as useDirectusFile } from './hooks/directus-file';
|
|
8
8
|
export { default as useDirectusLink } from './hooks/directus-link';
|
|
9
9
|
export { default as useNavigationItems } from './hooks/navigation-items';
|
|
10
|
+
export { default as useMetadata } from './hooks/directus-metadata';
|
package/types/links.d.ts
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { TPageSettings } from '@okam/directus-next';
|
|
2
|
+
import type { Nullable } from '@okam/stack-ui';
|
|
3
|
+
import type { AlternateURLs } from 'next/dist/lib/metadata/types/alternative-urls-types';
|
|
4
|
+
import type { OpenGraphType } from 'next/dist/lib/metadata/types/opengraph-types';
|
|
5
|
+
import type { StaticImageData } from 'next/image';
|
|
6
|
+
import type { TDirectusFileProps } from '../components/DirectusFile/interface';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for metadata generation
|
|
9
|
+
*/
|
|
10
|
+
export type TMetadataOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* Default fallback image to use for Open Graph tags when no other image is specified
|
|
13
|
+
*/
|
|
14
|
+
ogFallbackImage?: StaticImageData;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum width allowed for Open Graph images
|
|
17
|
+
*/
|
|
18
|
+
ogImageMaxWidth: number;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum height allowed for Open Graph images
|
|
21
|
+
*/
|
|
22
|
+
ogImageMaxHeight: number;
|
|
23
|
+
/**
|
|
24
|
+
* Custom image loader function to transform image URLs
|
|
25
|
+
* @param src Source URL of the image
|
|
26
|
+
* @param width Optional width to resize the image to
|
|
27
|
+
* @param height Optional height to resize the image to
|
|
28
|
+
* @returns Transformed image URL
|
|
29
|
+
*/
|
|
30
|
+
imageLoader: ({ src, width, height }: {
|
|
31
|
+
src: string;
|
|
32
|
+
width?: number | string;
|
|
33
|
+
height?: number | string;
|
|
34
|
+
}) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Get the files fragment from a directus_files object
|
|
37
|
+
* @param file The directus_files object
|
|
38
|
+
* @returns The files fragment
|
|
39
|
+
*/
|
|
40
|
+
getFilesFragment: <T extends {
|
|
41
|
+
_typename: 'directus_files';
|
|
42
|
+
}>(file: Nullable<T>) => Nullable<TDirectusFileProps>;
|
|
43
|
+
/**
|
|
44
|
+
* Create alternate URLs for the page
|
|
45
|
+
* @param pageSettings The page settings
|
|
46
|
+
* @returns The alternate URLs
|
|
47
|
+
*/
|
|
48
|
+
createAlternateUrls: (pageSettings: Nullable<TPageSettings>) => AlternateURLs;
|
|
49
|
+
/**
|
|
50
|
+
* The type config of Open Graph to use
|
|
51
|
+
* @param {string} key - The collection name
|
|
52
|
+
* @param {OpenGraphType} value - The og:type value
|
|
53
|
+
*/
|
|
54
|
+
openGraphTypeConfig: Record<string, OpenGraphType>;
|
|
55
|
+
/**
|
|
56
|
+
* Get the hostname
|
|
57
|
+
* @returns The hostname
|
|
58
|
+
*/
|
|
59
|
+
getHostname: () => string;
|
|
60
|
+
};
|
package/types/files.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type TFiles = {
|
|
2
|
-
id?: string | null;
|
|
3
|
-
title?: string | null;
|
|
4
|
-
description?: string | null;
|
|
5
|
-
tags?: any | null;
|
|
6
|
-
location?: string | null;
|
|
7
|
-
storage?: string | null;
|
|
8
|
-
focal_point_divider?: string | null;
|
|
9
|
-
focal_point_x?: number | null;
|
|
10
|
-
focal_point_y?: number | null;
|
|
11
|
-
filename_disk?: string | null;
|
|
12
|
-
filename_download?: string | null;
|
|
13
|
-
type?: string | null;
|
|
14
|
-
width?: number | null;
|
|
15
|
-
height?: number | null;
|
|
16
|
-
duration?: number | null;
|
|
17
|
-
embed?: string | null;
|
|
18
|
-
caption?: string | null;
|
|
19
|
-
thumbhash?: string | null;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `filename_download` instead
|
|
22
|
-
*/
|
|
23
|
-
filenameDownload?: string | null;
|
|
24
|
-
};
|
package/types/page-settings.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type TPageSettings = {
|
|
2
|
-
id: string;
|
|
3
|
-
belongs_to_collection?: string | null;
|
|
4
|
-
translations?: Array<{
|
|
5
|
-
slug?: string | null;
|
|
6
|
-
title?: string | null;
|
|
7
|
-
path?: string | null;
|
|
8
|
-
languages_code?: {
|
|
9
|
-
code: string;
|
|
10
|
-
} | null;
|
|
11
|
-
} | null> | null;
|
|
12
|
-
route?: {
|
|
13
|
-
translations?: Array<{
|
|
14
|
-
route?: string | null;
|
|
15
|
-
} | null> | null;
|
|
16
|
-
} | null;
|
|
17
|
-
};
|