@websolutespa/payload-plugin-bowl 1.3.5 → 1.3.6
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 +6 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +16 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -183,7 +183,6 @@ type IUndecoratedMenu = {
|
|
|
183
183
|
updatedAt: Date;
|
|
184
184
|
};
|
|
185
185
|
type MixerContext = {
|
|
186
|
-
slug?: string;
|
|
187
186
|
market?: string;
|
|
188
187
|
locale?: string;
|
|
189
188
|
routes?: IRoute[];
|
|
@@ -223,7 +222,7 @@ declare const pageIndexGet: ((slug: string) => Endpoint);
|
|
|
223
222
|
/**
|
|
224
223
|
* Decorate record for Mixer when queried by market and locale.
|
|
225
224
|
*/
|
|
226
|
-
declare const afterPageReadHook: CollectionConfig['hooks']['afterRead'][number];
|
|
225
|
+
declare const afterPageReadHook: (slug: string) => CollectionConfig['hooks']['afterRead'][number];
|
|
227
226
|
/**
|
|
228
227
|
* Create a record of the pages collection related to the created document.
|
|
229
228
|
*/
|
package/dist/index.js
CHANGED
|
@@ -4031,12 +4031,12 @@ function getSubRequest(req) {
|
|
|
4031
4031
|
return subRequest;
|
|
4032
4032
|
}
|
|
4033
4033
|
__name(getSubRequest, "getSubRequest");
|
|
4034
|
-
async function setMixerContext(req,
|
|
4034
|
+
async function setMixerContext(req, market, locale) {
|
|
4035
4035
|
const subRequest = getSubRequest(req);
|
|
4036
4036
|
const routes = await getRoutes(subRequest);
|
|
4037
4037
|
const categories = await getCollectionItems(subRequest, options.slug.category);
|
|
4038
4038
|
const richText = req.query?.richText === "true";
|
|
4039
|
-
Object.assign(req.context, {
|
|
4039
|
+
Object.assign(req.context, { market, locale, routes, categories, richText });
|
|
4040
4040
|
}
|
|
4041
4041
|
__name(setMixerContext, "setMixerContext");
|
|
4042
4042
|
var pageDetailGet = /* @__PURE__ */ __name((slug) => ({
|
|
@@ -4052,7 +4052,7 @@ var pageDetailGet = /* @__PURE__ */ __name((slug) => ({
|
|
|
4052
4052
|
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
4053
4053
|
return next();
|
|
4054
4054
|
}
|
|
4055
|
-
await setMixerContext(req,
|
|
4055
|
+
await setMixerContext(req, market, locale);
|
|
4056
4056
|
return next();
|
|
4057
4057
|
} catch (error) {
|
|
4058
4058
|
console.log("pageDetailGet.error", error);
|
|
@@ -4073,7 +4073,7 @@ var pageIndexGet = /* @__PURE__ */ __name((slug) => ({
|
|
|
4073
4073
|
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
4074
4074
|
return next();
|
|
4075
4075
|
}
|
|
4076
|
-
await setMixerContext(req,
|
|
4076
|
+
await setMixerContext(req, market, locale);
|
|
4077
4077
|
if (limit === "10000") {
|
|
4078
4078
|
return next();
|
|
4079
4079
|
}
|
|
@@ -4089,15 +4089,15 @@ var pageIndexGet = /* @__PURE__ */ __name((slug) => ({
|
|
|
4089
4089
|
}
|
|
4090
4090
|
}
|
|
4091
4091
|
}), "pageIndexGet");
|
|
4092
|
-
var afterPageReadHook = /* @__PURE__ */ __name(async ({
|
|
4092
|
+
var afterPageReadHook = /* @__PURE__ */ __name((slug) => async ({
|
|
4093
4093
|
doc,
|
|
4094
4094
|
req,
|
|
4095
4095
|
query,
|
|
4096
4096
|
findMany,
|
|
4097
4097
|
context
|
|
4098
4098
|
}) => {
|
|
4099
|
-
const {
|
|
4100
|
-
if (!
|
|
4099
|
+
const { market, locale, routes, categories } = context;
|
|
4100
|
+
if (!market || !locale || !routes || !categories) {
|
|
4101
4101
|
return doc;
|
|
4102
4102
|
}
|
|
4103
4103
|
const withSchema = await decorateSchema_(doc, slug, market, locale, categories, routes);
|
|
@@ -4764,15 +4764,20 @@ var PageDefault = {
|
|
|
4764
4764
|
hooks: {
|
|
4765
4765
|
// beforeValidate: [beforeValidateHook],
|
|
4766
4766
|
afterChange: [afterPageChangeHook],
|
|
4767
|
-
afterDelete: [afterPageDeleteHook]
|
|
4768
|
-
afterRead: [afterPageReadHook]
|
|
4767
|
+
afterDelete: [afterPageDeleteHook]
|
|
4769
4768
|
},
|
|
4770
4769
|
versions: {
|
|
4771
4770
|
drafts: true
|
|
4772
4771
|
}
|
|
4773
4772
|
};
|
|
4774
4773
|
var withPage = /* @__PURE__ */ __name((config) => {
|
|
4775
|
-
const defaultConfig = {
|
|
4774
|
+
const defaultConfig = {
|
|
4775
|
+
...PageDefault,
|
|
4776
|
+
hooks: {
|
|
4777
|
+
...PageDefault.hooks,
|
|
4778
|
+
afterRead: [afterPageReadHook(config.slug)]
|
|
4779
|
+
}
|
|
4780
|
+
};
|
|
4776
4781
|
defaultConfig.admin.preview = (doc, { locale, token }) => {
|
|
4777
4782
|
const PREVIEW_URL = process.env.PAYLOAD_PUBLIC_PREVIEW_URL || "https://localhost:3000";
|
|
4778
4783
|
const localeId = locale;
|
|
@@ -4783,7 +4788,7 @@ var withPage = /* @__PURE__ */ __name((config) => {
|
|
|
4783
4788
|
const _status = doc._status;
|
|
4784
4789
|
return `${PREVIEW_URL}/${marketId}/${localeId}/${templateId}/${doc.id}?_status=${_status}${token ? `&token=${token}` : ""}`;
|
|
4785
4790
|
};
|
|
4786
|
-
const pageConfig = deepMerge(
|
|
4791
|
+
const pageConfig = deepMerge(defaultConfig, config);
|
|
4787
4792
|
pageConfig.fields = [
|
|
4788
4793
|
withTitleRequired(),
|
|
4789
4794
|
// sidebar
|