@littlebox/strapi-suite 1.0.39 → 1.0.41
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/_chunks/{App-2SwRpCFC.mjs → App-CPtEzTxB.mjs} +3 -3
- package/dist/_chunks/{App-DBXgA-D1.js → App-Cp8XmCTY.js} +3 -3
- package/dist/_chunks/{SlugInput-BcUe-oCY.mjs → SlugInput-CfdpwmaN.mjs} +2 -2
- package/dist/_chunks/{SlugInput-CVnNz0al.js → SlugInput-DlNZvvV5.js} +2 -2
- package/dist/_chunks/{convertToSlug-q9_W-VMA.mjs → convertToSlug-B8n8-z6F.mjs} +1 -1
- package/dist/_chunks/{convertToSlug-Btfca6aI.js → convertToSlug-M7bBnlxy.js} +1 -1
- package/dist/_chunks/{index-DmkEUACh.mjs → index-B77yEKma.mjs} +2 -2
- package/dist/_chunks/{index-Pylfg-hk.js → index-DykVJfCn.js} +2 -2
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +157 -12
- package/dist/server/index.mjs +157 -12
- package/dist/server/src/utils/buildBreadcrumbs.d.ts +16 -0
- package/package.json +1 -1
|
@@ -2,12 +2,12 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { useNavigate, useParams, Routes, Route } from "react-router-dom";
|
|
3
3
|
import React__default, { useState, useEffect, createContext, useContext, Fragment as Fragment$1, useRef } from "react";
|
|
4
4
|
import { Box, Loader, Main, Typography, Button, Flex, Breadcrumbs, Crumb, CrumbLink, CardBody, CardContent, CardTitle, CardBadge, CardSubtitle, Card as Card$1, Dialog, IconButton, Toggle, SingleSelect, SingleSelectOption, SearchForm, Searchbar, Table, Thead, Tr, Th, Checkbox, VisuallyHidden, Tbody, Td, EmptyStateLayout, TextInput, Field, Tooltip } from "@strapi/design-system";
|
|
5
|
-
import { R as Registry, F as FetchSettings, g as getTranslation, c as config, S as SLUG_LANGUAGE_STRATEGY, a as SLUG_CONTENT_STRATEGY, b as FetchSlugs, f as fetchTemplates } from "./index-
|
|
5
|
+
import { R as Registry, F as FetchSettings, g as getTranslation, c as config, S as SLUG_LANGUAGE_STRATEGY, a as SLUG_CONTENT_STRATEGY, b as FetchSlugs, f as fetchTemplates } from "./index-B77yEKma.mjs";
|
|
6
6
|
import { ArrowLeft, ExternalLink, WarningCircle, Cross, BulletList, Pencil, Trash, Plus, Duplicate, Drag, Check } from "@strapi/icons";
|
|
7
7
|
import { useIntl } from "react-intl";
|
|
8
8
|
import styled, { useTheme } from "styled-components";
|
|
9
9
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
10
|
-
import { F as FetchLocales, c as convertToSlug } from "./convertToSlug-
|
|
10
|
+
import { F as FetchLocales, c as convertToSlug } from "./convertToSlug-B8n8-z6F.mjs";
|
|
11
11
|
import { DndContext, DragOverlay, pointerWithin, rectIntersection } from "@dnd-kit/core";
|
|
12
12
|
import { useSortable, SortableContext, verticalListSortingStrategy, arrayMove } from "@dnd-kit/sortable";
|
|
13
13
|
import { restrictToVerticalAxis, restrictToParentElement } from "@dnd-kit/modifiers";
|
|
@@ -716,7 +716,7 @@ const HomePage = () => {
|
|
|
716
716
|
variant: "tertiary",
|
|
717
717
|
style: { marginRight: "10px" },
|
|
718
718
|
endIcon: /* @__PURE__ */ jsx(ExternalLink, {}),
|
|
719
|
-
onClick: () => window.open("https://strapi.littlebox.pt", "_blank"),
|
|
719
|
+
onClick: () => window.open("https://strapi-suite.littlebox.pt", "_blank"),
|
|
720
720
|
children: formatMessage({ id: getTranslation("app.documentation") })
|
|
721
721
|
}
|
|
722
722
|
),
|
|
@@ -4,12 +4,12 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const reactRouterDom = require("react-router-dom");
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const designSystem = require("@strapi/design-system");
|
|
7
|
-
const index = require("./index-
|
|
7
|
+
const index = require("./index-DykVJfCn.js");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
9
|
const reactIntl = require("react-intl");
|
|
10
10
|
const styled = require("styled-components");
|
|
11
11
|
const symbols = require("@strapi/icons/symbols");
|
|
12
|
-
const convertToSlug = require("./convertToSlug-
|
|
12
|
+
const convertToSlug = require("./convertToSlug-M7bBnlxy.js");
|
|
13
13
|
const core = require("@dnd-kit/core");
|
|
14
14
|
const sortable = require("@dnd-kit/sortable");
|
|
15
15
|
const modifiers = require("@dnd-kit/modifiers");
|
|
@@ -721,7 +721,7 @@ const HomePage = () => {
|
|
|
721
721
|
variant: "tertiary",
|
|
722
722
|
style: { marginRight: "10px" },
|
|
723
723
|
endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ExternalLink, {}),
|
|
724
|
-
onClick: () => window.open("https://strapi.littlebox.pt", "_blank"),
|
|
724
|
+
onClick: () => window.open("https://strapi-suite.littlebox.pt", "_blank"),
|
|
725
725
|
children: formatMessage({ id: index.getTranslation("app.documentation") })
|
|
726
726
|
}
|
|
727
727
|
),
|
|
@@ -6,8 +6,8 @@ import { useComposedRefs, Field, Box, Typography, TextInput, IconButton, Button
|
|
|
6
6
|
import { Pin, Cross } from "@strapi/icons";
|
|
7
7
|
import { useFocusInputField, unstable_useContentManagerContext } from "@strapi/strapi/admin";
|
|
8
8
|
import styled from "styled-components";
|
|
9
|
-
import { R as Registry, P as PageAttributeUpdated, D as DocumentCustomFieldStarted, d as PluginIcon, g as getTranslation, c as config, e as FetchModuleSettings } from "./index-
|
|
10
|
-
import { c as convertToSlug, F as FetchLocales } from "./convertToSlug-
|
|
9
|
+
import { R as Registry, P as PageAttributeUpdated, D as DocumentCustomFieldStarted, d as PluginIcon, g as getTranslation, c as config, e as FetchModuleSettings } from "./index-B77yEKma.mjs";
|
|
10
|
+
import { c as convertToSlug, F as FetchLocales } from "./convertToSlug-B8n8-z6F.mjs";
|
|
11
11
|
const BoxInput = styled(Box)`
|
|
12
12
|
& > div {
|
|
13
13
|
width: 100%;
|
|
@@ -8,8 +8,8 @@ const designSystem = require("@strapi/design-system");
|
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
9
|
const admin = require("@strapi/strapi/admin");
|
|
10
10
|
const styled = require("styled-components");
|
|
11
|
-
const index = require("./index-
|
|
12
|
-
const convertToSlug = require("./convertToSlug-
|
|
11
|
+
const index = require("./index-DykVJfCn.js");
|
|
12
|
+
const convertToSlug = require("./convertToSlug-M7bBnlxy.js");
|
|
13
13
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
14
|
function _interopNamespace(e) {
|
|
15
15
|
if (e && e.__esModule) return e;
|
|
@@ -3303,7 +3303,7 @@ const index = {
|
|
|
3303
3303
|
defaultMessage: config.pluginId
|
|
3304
3304
|
},
|
|
3305
3305
|
position: 999,
|
|
3306
|
-
Component: () => import("./App-
|
|
3306
|
+
Component: () => import("./App-CPtEzTxB.mjs")
|
|
3307
3307
|
});
|
|
3308
3308
|
app.customFields.register({
|
|
3309
3309
|
name: "ltbslug",
|
|
@@ -3321,7 +3321,7 @@ const index = {
|
|
|
3321
3321
|
components: {
|
|
3322
3322
|
Input: async () => import(
|
|
3323
3323
|
/* webpackChunkName: "input-slug-component" */
|
|
3324
|
-
"./SlugInput-
|
|
3324
|
+
"./SlugInput-CfdpwmaN.mjs"
|
|
3325
3325
|
)
|
|
3326
3326
|
},
|
|
3327
3327
|
options: {
|
|
@@ -3306,7 +3306,7 @@ const index = {
|
|
|
3306
3306
|
defaultMessage: config.pluginId
|
|
3307
3307
|
},
|
|
3308
3308
|
position: 999,
|
|
3309
|
-
Component: () => Promise.resolve().then(() => require("./App-
|
|
3309
|
+
Component: () => Promise.resolve().then(() => require("./App-Cp8XmCTY.js"))
|
|
3310
3310
|
});
|
|
3311
3311
|
app.customFields.register({
|
|
3312
3312
|
name: "ltbslug",
|
|
@@ -3324,7 +3324,7 @@ const index = {
|
|
|
3324
3324
|
components: {
|
|
3325
3325
|
Input: async () => Promise.resolve().then(() => require(
|
|
3326
3326
|
/* webpackChunkName: "input-slug-component" */
|
|
3327
|
-
"./SlugInput-
|
|
3327
|
+
"./SlugInput-DlNZvvV5.js"
|
|
3328
3328
|
))
|
|
3329
3329
|
},
|
|
3330
3330
|
options: {
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const PLUGIN_ID = "littlebox-strapi-suite";
|
|
3
3
|
const SLUG_LANGUAGE_STRATEGY = "language";
|
|
4
|
+
const SLUG_CONTENT_STRATEGY = "content";
|
|
4
5
|
const config = {
|
|
5
6
|
default: {
|
|
6
7
|
pluginId: PLUGIN_ID,
|
|
@@ -1635,6 +1636,101 @@ function buildFullSlug(params) {
|
|
|
1635
1636
|
});
|
|
1636
1637
|
return `${parentFullSlug}/${params.page.slug}`;
|
|
1637
1638
|
}
|
|
1639
|
+
async function build(params) {
|
|
1640
|
+
const config2 = strapi.config.get(`plugin::${PLUGIN_ID}`);
|
|
1641
|
+
const document = await strapi.documents(params.page.contentModel).findOne({
|
|
1642
|
+
locale: params.page.locale,
|
|
1643
|
+
status: "published",
|
|
1644
|
+
documentId: params.page.contentId
|
|
1645
|
+
});
|
|
1646
|
+
if (!params.page.parentContentId || !params.page.parentContentModel) {
|
|
1647
|
+
return [
|
|
1648
|
+
{
|
|
1649
|
+
name: document.title,
|
|
1650
|
+
slug: params.page.slug
|
|
1651
|
+
}
|
|
1652
|
+
];
|
|
1653
|
+
}
|
|
1654
|
+
const parentPage = await strapi.db.query(config2.uuid.modules.slug).findOne({
|
|
1655
|
+
where: {
|
|
1656
|
+
state: "published",
|
|
1657
|
+
contentId: params.page.parentContentId,
|
|
1658
|
+
contentModel: params.page.parentContentModel,
|
|
1659
|
+
locale: params.page.locale
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
const parentBreadcrumb = await build({
|
|
1663
|
+
strapi: params.strapi,
|
|
1664
|
+
page: parentPage,
|
|
1665
|
+
defaultLocale: params.defaultLocale,
|
|
1666
|
+
showDefaultLanguage: params.showDefaultLanguage
|
|
1667
|
+
});
|
|
1668
|
+
return [
|
|
1669
|
+
...parentBreadcrumb,
|
|
1670
|
+
{
|
|
1671
|
+
name: document.title,
|
|
1672
|
+
slug: params.page.slug
|
|
1673
|
+
}
|
|
1674
|
+
];
|
|
1675
|
+
}
|
|
1676
|
+
async function buildBreadcrumbs(params) {
|
|
1677
|
+
const isHomepage = params.page.contentId === params.homepageContentId && params.page.contentModel === params.homepageContentModel;
|
|
1678
|
+
const result = await build({
|
|
1679
|
+
strapi: params.strapi,
|
|
1680
|
+
page: params.page,
|
|
1681
|
+
defaultLocale: params.defaultLocale,
|
|
1682
|
+
showDefaultLanguage: params.showDefaultLanguage
|
|
1683
|
+
});
|
|
1684
|
+
if (isHomepage) {
|
|
1685
|
+
result[0].slug = "";
|
|
1686
|
+
if (params.defaultLocale !== params.page.locale) {
|
|
1687
|
+
result[0].slug = params.homepageSlugStrategy === SLUG_CONTENT_STRATEGY ? `${params.page.locale.toLowerCase()}/${params.page.slug}` : params.page.locale.toLowerCase();
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
if (!isHomepage) {
|
|
1691
|
+
const config2 = strapi.config.get(`plugin::${PLUGIN_ID}`);
|
|
1692
|
+
const page = await strapi.db.query(config2.uuid.modules.slug).findOne({
|
|
1693
|
+
where: {
|
|
1694
|
+
locale: params.page.locale,
|
|
1695
|
+
contentId: params.homepageContentId,
|
|
1696
|
+
contentModel: params.homepageContentModel,
|
|
1697
|
+
state: "published"
|
|
1698
|
+
}
|
|
1699
|
+
});
|
|
1700
|
+
const document = await strapi.documents(params.homepageContentModel).findOne({
|
|
1701
|
+
locale: params.page.locale,
|
|
1702
|
+
status: "published",
|
|
1703
|
+
documentId: params.homepageContentId
|
|
1704
|
+
});
|
|
1705
|
+
let slug = "";
|
|
1706
|
+
if (params.defaultLocale !== params.page.locale) {
|
|
1707
|
+
slug = params.homepageSlugStrategy === SLUG_CONTENT_STRATEGY ? `${params.page.locale.toLowerCase()}/${page.slug}` : params.page.locale.toLowerCase();
|
|
1708
|
+
}
|
|
1709
|
+
result.unshift({
|
|
1710
|
+
name: document.title,
|
|
1711
|
+
slug
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
const mappedResult = result.reduce((acc, currentItem, index2) => {
|
|
1715
|
+
const mappedItem = {
|
|
1716
|
+
position: index2 + 1,
|
|
1717
|
+
item: currentItem.slug,
|
|
1718
|
+
name: currentItem.name
|
|
1719
|
+
};
|
|
1720
|
+
if (index2 === 1 && params.defaultLocale === params.page.locale) {
|
|
1721
|
+
mappedItem.item = params.showDefaultLanguage ? `${params.page.locale}/${currentItem.slug}` : currentItem.slug;
|
|
1722
|
+
}
|
|
1723
|
+
if (index2 === 1 && params.defaultLocale !== params.page.locale) {
|
|
1724
|
+
mappedItem.item = `${params.page.locale}/${currentItem.slug}`;
|
|
1725
|
+
}
|
|
1726
|
+
if (index2 > 1) {
|
|
1727
|
+
mappedItem.item = `${acc[index2 - 1].item}/${currentItem.slug}`;
|
|
1728
|
+
}
|
|
1729
|
+
acc.push(mappedItem);
|
|
1730
|
+
return acc;
|
|
1731
|
+
}, []);
|
|
1732
|
+
return mappedResult;
|
|
1733
|
+
}
|
|
1638
1734
|
function handleAttributes(attributes2) {
|
|
1639
1735
|
const query = {};
|
|
1640
1736
|
Object.keys(attributes2).forEach((key) => {
|
|
@@ -1720,13 +1816,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1720
1816
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1721
1817
|
where: {
|
|
1722
1818
|
module: "slug",
|
|
1723
|
-
property: [
|
|
1819
|
+
property: [
|
|
1820
|
+
"showDefaultLanguage",
|
|
1821
|
+
"homepageContentId",
|
|
1822
|
+
"homepageContentModel",
|
|
1823
|
+
"homepageSlugStrategy"
|
|
1824
|
+
]
|
|
1724
1825
|
}
|
|
1725
1826
|
});
|
|
1726
1827
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1727
|
-
const homepageContentId = settings.find(
|
|
1728
|
-
|
|
1729
|
-
|
|
1828
|
+
const homepageContentId = settings.find(
|
|
1829
|
+
(setting) => setting.property === "homepageContentId"
|
|
1830
|
+
).value;
|
|
1831
|
+
const homepageSlugStrategy = settings.find(
|
|
1832
|
+
(setting) => setting.property === "homepageSlugStrategy"
|
|
1833
|
+
).value;
|
|
1834
|
+
const homepageContentModel = settings.find(
|
|
1835
|
+
(setting) => setting.property === "homepageContentModel"
|
|
1836
|
+
).value;
|
|
1730
1837
|
let page;
|
|
1731
1838
|
if (homepageSlugStrategy === SLUG_LANGUAGE_STRATEGY && mappedLocales.includes(slug)) {
|
|
1732
1839
|
page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
@@ -1799,6 +1906,15 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1799
1906
|
delete document.createdBy;
|
|
1800
1907
|
delete document.updatedBy;
|
|
1801
1908
|
document.slug = page.fullSlug;
|
|
1909
|
+
document.breadcrumbs = await buildBreadcrumbs({
|
|
1910
|
+
strapi: strapi2,
|
|
1911
|
+
page,
|
|
1912
|
+
defaultLocale,
|
|
1913
|
+
showDefaultLanguage,
|
|
1914
|
+
homepageSlugStrategy,
|
|
1915
|
+
homepageContentId,
|
|
1916
|
+
homepageContentModel
|
|
1917
|
+
});
|
|
1802
1918
|
return {
|
|
1803
1919
|
document,
|
|
1804
1920
|
...page.attributes ? { attributes: page.attributes } : {}
|
|
@@ -1812,13 +1928,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1812
1928
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1813
1929
|
where: {
|
|
1814
1930
|
module: "slug",
|
|
1815
|
-
property: [
|
|
1931
|
+
property: [
|
|
1932
|
+
"showDefaultLanguage",
|
|
1933
|
+
"homepageContentId",
|
|
1934
|
+
"homepageContentModel",
|
|
1935
|
+
"homepageSlugStrategy"
|
|
1936
|
+
]
|
|
1816
1937
|
}
|
|
1817
1938
|
});
|
|
1818
1939
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1819
|
-
const homepageContentId = settings.find(
|
|
1820
|
-
|
|
1821
|
-
|
|
1940
|
+
const homepageContentId = settings.find(
|
|
1941
|
+
(setting) => setting.property === "homepageContentId"
|
|
1942
|
+
).value;
|
|
1943
|
+
const homepageContentModel = settings.find(
|
|
1944
|
+
(setting) => setting.property === "homepageContentModel"
|
|
1945
|
+
).value;
|
|
1946
|
+
const homepageSlugStrategy = settings.find(
|
|
1947
|
+
(setting) => setting.property === "homepageSlugStrategy"
|
|
1948
|
+
).value;
|
|
1822
1949
|
const pages = await strapi2.db.query(config2.uuid.modules.slug).findMany({
|
|
1823
1950
|
where: {
|
|
1824
1951
|
state: "published"
|
|
@@ -1896,13 +2023,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1896
2023
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1897
2024
|
where: {
|
|
1898
2025
|
module: "slug",
|
|
1899
|
-
property: [
|
|
2026
|
+
property: [
|
|
2027
|
+
"showDefaultLanguage",
|
|
2028
|
+
"homepageContentId",
|
|
2029
|
+
"homepageContentModel",
|
|
2030
|
+
"homepageSlugStrategy"
|
|
2031
|
+
]
|
|
1900
2032
|
}
|
|
1901
2033
|
});
|
|
1902
2034
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1903
|
-
const homepageContentId = settings.find(
|
|
1904
|
-
|
|
1905
|
-
|
|
2035
|
+
const homepageContentId = settings.find(
|
|
2036
|
+
(setting) => setting.property === "homepageContentId"
|
|
2037
|
+
).value;
|
|
2038
|
+
const homepageContentModel = settings.find(
|
|
2039
|
+
(setting) => setting.property === "homepageContentModel"
|
|
2040
|
+
).value;
|
|
2041
|
+
const homepageSlugStrategy = settings.find(
|
|
2042
|
+
(setting) => setting.property === "homepageSlugStrategy"
|
|
2043
|
+
).value;
|
|
1906
2044
|
const page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
1907
2045
|
where: {
|
|
1908
2046
|
state: "published",
|
|
@@ -1960,6 +2098,13 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1960
2098
|
delete document.createdBy;
|
|
1961
2099
|
delete document.updatedBy;
|
|
1962
2100
|
document.slug = "";
|
|
2101
|
+
document.breadcrumbs = [
|
|
2102
|
+
{
|
|
2103
|
+
position: 1,
|
|
2104
|
+
name: document.title,
|
|
2105
|
+
item: ""
|
|
2106
|
+
}
|
|
2107
|
+
];
|
|
1963
2108
|
return {
|
|
1964
2109
|
document,
|
|
1965
2110
|
...page.attributes ? { attributes: page.attributes } : {}
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const PLUGIN_ID = "littlebox-strapi-suite";
|
|
2
2
|
const SLUG_LANGUAGE_STRATEGY = "language";
|
|
3
|
+
const SLUG_CONTENT_STRATEGY = "content";
|
|
3
4
|
const config = {
|
|
4
5
|
default: {
|
|
5
6
|
pluginId: PLUGIN_ID,
|
|
@@ -1634,6 +1635,101 @@ function buildFullSlug(params) {
|
|
|
1634
1635
|
});
|
|
1635
1636
|
return `${parentFullSlug}/${params.page.slug}`;
|
|
1636
1637
|
}
|
|
1638
|
+
async function build(params) {
|
|
1639
|
+
const config2 = strapi.config.get(`plugin::${PLUGIN_ID}`);
|
|
1640
|
+
const document = await strapi.documents(params.page.contentModel).findOne({
|
|
1641
|
+
locale: params.page.locale,
|
|
1642
|
+
status: "published",
|
|
1643
|
+
documentId: params.page.contentId
|
|
1644
|
+
});
|
|
1645
|
+
if (!params.page.parentContentId || !params.page.parentContentModel) {
|
|
1646
|
+
return [
|
|
1647
|
+
{
|
|
1648
|
+
name: document.title,
|
|
1649
|
+
slug: params.page.slug
|
|
1650
|
+
}
|
|
1651
|
+
];
|
|
1652
|
+
}
|
|
1653
|
+
const parentPage = await strapi.db.query(config2.uuid.modules.slug).findOne({
|
|
1654
|
+
where: {
|
|
1655
|
+
state: "published",
|
|
1656
|
+
contentId: params.page.parentContentId,
|
|
1657
|
+
contentModel: params.page.parentContentModel,
|
|
1658
|
+
locale: params.page.locale
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1661
|
+
const parentBreadcrumb = await build({
|
|
1662
|
+
strapi: params.strapi,
|
|
1663
|
+
page: parentPage,
|
|
1664
|
+
defaultLocale: params.defaultLocale,
|
|
1665
|
+
showDefaultLanguage: params.showDefaultLanguage
|
|
1666
|
+
});
|
|
1667
|
+
return [
|
|
1668
|
+
...parentBreadcrumb,
|
|
1669
|
+
{
|
|
1670
|
+
name: document.title,
|
|
1671
|
+
slug: params.page.slug
|
|
1672
|
+
}
|
|
1673
|
+
];
|
|
1674
|
+
}
|
|
1675
|
+
async function buildBreadcrumbs(params) {
|
|
1676
|
+
const isHomepage = params.page.contentId === params.homepageContentId && params.page.contentModel === params.homepageContentModel;
|
|
1677
|
+
const result = await build({
|
|
1678
|
+
strapi: params.strapi,
|
|
1679
|
+
page: params.page,
|
|
1680
|
+
defaultLocale: params.defaultLocale,
|
|
1681
|
+
showDefaultLanguage: params.showDefaultLanguage
|
|
1682
|
+
});
|
|
1683
|
+
if (isHomepage) {
|
|
1684
|
+
result[0].slug = "";
|
|
1685
|
+
if (params.defaultLocale !== params.page.locale) {
|
|
1686
|
+
result[0].slug = params.homepageSlugStrategy === SLUG_CONTENT_STRATEGY ? `${params.page.locale.toLowerCase()}/${params.page.slug}` : params.page.locale.toLowerCase();
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
if (!isHomepage) {
|
|
1690
|
+
const config2 = strapi.config.get(`plugin::${PLUGIN_ID}`);
|
|
1691
|
+
const page = await strapi.db.query(config2.uuid.modules.slug).findOne({
|
|
1692
|
+
where: {
|
|
1693
|
+
locale: params.page.locale,
|
|
1694
|
+
contentId: params.homepageContentId,
|
|
1695
|
+
contentModel: params.homepageContentModel,
|
|
1696
|
+
state: "published"
|
|
1697
|
+
}
|
|
1698
|
+
});
|
|
1699
|
+
const document = await strapi.documents(params.homepageContentModel).findOne({
|
|
1700
|
+
locale: params.page.locale,
|
|
1701
|
+
status: "published",
|
|
1702
|
+
documentId: params.homepageContentId
|
|
1703
|
+
});
|
|
1704
|
+
let slug = "";
|
|
1705
|
+
if (params.defaultLocale !== params.page.locale) {
|
|
1706
|
+
slug = params.homepageSlugStrategy === SLUG_CONTENT_STRATEGY ? `${params.page.locale.toLowerCase()}/${page.slug}` : params.page.locale.toLowerCase();
|
|
1707
|
+
}
|
|
1708
|
+
result.unshift({
|
|
1709
|
+
name: document.title,
|
|
1710
|
+
slug
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
const mappedResult = result.reduce((acc, currentItem, index2) => {
|
|
1714
|
+
const mappedItem = {
|
|
1715
|
+
position: index2 + 1,
|
|
1716
|
+
item: currentItem.slug,
|
|
1717
|
+
name: currentItem.name
|
|
1718
|
+
};
|
|
1719
|
+
if (index2 === 1 && params.defaultLocale === params.page.locale) {
|
|
1720
|
+
mappedItem.item = params.showDefaultLanguage ? `${params.page.locale}/${currentItem.slug}` : currentItem.slug;
|
|
1721
|
+
}
|
|
1722
|
+
if (index2 === 1 && params.defaultLocale !== params.page.locale) {
|
|
1723
|
+
mappedItem.item = `${params.page.locale}/${currentItem.slug}`;
|
|
1724
|
+
}
|
|
1725
|
+
if (index2 > 1) {
|
|
1726
|
+
mappedItem.item = `${acc[index2 - 1].item}/${currentItem.slug}`;
|
|
1727
|
+
}
|
|
1728
|
+
acc.push(mappedItem);
|
|
1729
|
+
return acc;
|
|
1730
|
+
}, []);
|
|
1731
|
+
return mappedResult;
|
|
1732
|
+
}
|
|
1637
1733
|
function handleAttributes(attributes2) {
|
|
1638
1734
|
const query = {};
|
|
1639
1735
|
Object.keys(attributes2).forEach((key) => {
|
|
@@ -1719,13 +1815,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1719
1815
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1720
1816
|
where: {
|
|
1721
1817
|
module: "slug",
|
|
1722
|
-
property: [
|
|
1818
|
+
property: [
|
|
1819
|
+
"showDefaultLanguage",
|
|
1820
|
+
"homepageContentId",
|
|
1821
|
+
"homepageContentModel",
|
|
1822
|
+
"homepageSlugStrategy"
|
|
1823
|
+
]
|
|
1723
1824
|
}
|
|
1724
1825
|
});
|
|
1725
1826
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1726
|
-
const homepageContentId = settings.find(
|
|
1727
|
-
|
|
1728
|
-
|
|
1827
|
+
const homepageContentId = settings.find(
|
|
1828
|
+
(setting) => setting.property === "homepageContentId"
|
|
1829
|
+
).value;
|
|
1830
|
+
const homepageSlugStrategy = settings.find(
|
|
1831
|
+
(setting) => setting.property === "homepageSlugStrategy"
|
|
1832
|
+
).value;
|
|
1833
|
+
const homepageContentModel = settings.find(
|
|
1834
|
+
(setting) => setting.property === "homepageContentModel"
|
|
1835
|
+
).value;
|
|
1729
1836
|
let page;
|
|
1730
1837
|
if (homepageSlugStrategy === SLUG_LANGUAGE_STRATEGY && mappedLocales.includes(slug)) {
|
|
1731
1838
|
page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
@@ -1798,6 +1905,15 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1798
1905
|
delete document.createdBy;
|
|
1799
1906
|
delete document.updatedBy;
|
|
1800
1907
|
document.slug = page.fullSlug;
|
|
1908
|
+
document.breadcrumbs = await buildBreadcrumbs({
|
|
1909
|
+
strapi: strapi2,
|
|
1910
|
+
page,
|
|
1911
|
+
defaultLocale,
|
|
1912
|
+
showDefaultLanguage,
|
|
1913
|
+
homepageSlugStrategy,
|
|
1914
|
+
homepageContentId,
|
|
1915
|
+
homepageContentModel
|
|
1916
|
+
});
|
|
1801
1917
|
return {
|
|
1802
1918
|
document,
|
|
1803
1919
|
...page.attributes ? { attributes: page.attributes } : {}
|
|
@@ -1811,13 +1927,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1811
1927
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1812
1928
|
where: {
|
|
1813
1929
|
module: "slug",
|
|
1814
|
-
property: [
|
|
1930
|
+
property: [
|
|
1931
|
+
"showDefaultLanguage",
|
|
1932
|
+
"homepageContentId",
|
|
1933
|
+
"homepageContentModel",
|
|
1934
|
+
"homepageSlugStrategy"
|
|
1935
|
+
]
|
|
1815
1936
|
}
|
|
1816
1937
|
});
|
|
1817
1938
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1818
|
-
const homepageContentId = settings.find(
|
|
1819
|
-
|
|
1820
|
-
|
|
1939
|
+
const homepageContentId = settings.find(
|
|
1940
|
+
(setting) => setting.property === "homepageContentId"
|
|
1941
|
+
).value;
|
|
1942
|
+
const homepageContentModel = settings.find(
|
|
1943
|
+
(setting) => setting.property === "homepageContentModel"
|
|
1944
|
+
).value;
|
|
1945
|
+
const homepageSlugStrategy = settings.find(
|
|
1946
|
+
(setting) => setting.property === "homepageSlugStrategy"
|
|
1947
|
+
).value;
|
|
1821
1948
|
const pages = await strapi2.db.query(config2.uuid.modules.slug).findMany({
|
|
1822
1949
|
where: {
|
|
1823
1950
|
state: "published"
|
|
@@ -1895,13 +2022,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1895
2022
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1896
2023
|
where: {
|
|
1897
2024
|
module: "slug",
|
|
1898
|
-
property: [
|
|
2025
|
+
property: [
|
|
2026
|
+
"showDefaultLanguage",
|
|
2027
|
+
"homepageContentId",
|
|
2028
|
+
"homepageContentModel",
|
|
2029
|
+
"homepageSlugStrategy"
|
|
2030
|
+
]
|
|
1899
2031
|
}
|
|
1900
2032
|
});
|
|
1901
2033
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1902
|
-
const homepageContentId = settings.find(
|
|
1903
|
-
|
|
1904
|
-
|
|
2034
|
+
const homepageContentId = settings.find(
|
|
2035
|
+
(setting) => setting.property === "homepageContentId"
|
|
2036
|
+
).value;
|
|
2037
|
+
const homepageContentModel = settings.find(
|
|
2038
|
+
(setting) => setting.property === "homepageContentModel"
|
|
2039
|
+
).value;
|
|
2040
|
+
const homepageSlugStrategy = settings.find(
|
|
2041
|
+
(setting) => setting.property === "homepageSlugStrategy"
|
|
2042
|
+
).value;
|
|
1905
2043
|
const page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
1906
2044
|
where: {
|
|
1907
2045
|
state: "published",
|
|
@@ -1959,6 +2097,13 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1959
2097
|
delete document.createdBy;
|
|
1960
2098
|
delete document.updatedBy;
|
|
1961
2099
|
document.slug = "";
|
|
2100
|
+
document.breadcrumbs = [
|
|
2101
|
+
{
|
|
2102
|
+
position: 1,
|
|
2103
|
+
name: document.title,
|
|
2104
|
+
item: ""
|
|
2105
|
+
}
|
|
2106
|
+
];
|
|
1962
2107
|
return {
|
|
1963
2108
|
document,
|
|
1964
2109
|
...page.attributes ? { attributes: page.attributes } : {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
export declare function build(params: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
page: any;
|
|
5
|
+
defaultLocale: any;
|
|
6
|
+
showDefaultLanguage: any;
|
|
7
|
+
}): any;
|
|
8
|
+
export declare function buildBreadcrumbs(params: {
|
|
9
|
+
strapi: Core.Strapi;
|
|
10
|
+
page: any;
|
|
11
|
+
defaultLocale: any;
|
|
12
|
+
showDefaultLanguage: any;
|
|
13
|
+
homepageSlugStrategy: any;
|
|
14
|
+
homepageContentId: any;
|
|
15
|
+
homepageContentModel: any;
|
|
16
|
+
}): Promise<any>;
|
package/package.json
CHANGED