@littlebox/strapi-suite 1.0.37 → 1.0.40
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/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,133 @@ 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
|
+
}
|
|
1734
|
+
function handleAttributes(attributes2) {
|
|
1735
|
+
const query = {};
|
|
1736
|
+
Object.keys(attributes2).forEach((key) => {
|
|
1737
|
+
switch (attributes2[key]["type"]) {
|
|
1738
|
+
case "component":
|
|
1739
|
+
const componentData = strapi.components[attributes2[key]["component"]];
|
|
1740
|
+
query[key] = { populate: handleAttributes(componentData.attributes) };
|
|
1741
|
+
break;
|
|
1742
|
+
case "media":
|
|
1743
|
+
query[key] = { populate: "*" };
|
|
1744
|
+
break;
|
|
1745
|
+
case "relation":
|
|
1746
|
+
if (key === "roles" || key === "users" || key === "createdBy" || key === "updatedBy") break;
|
|
1747
|
+
query[key] = key === "localizations" ? { populate: "*" } : { populate: populateQueryFromContentType(strapi, attributes2[key]["target"]) };
|
|
1748
|
+
break;
|
|
1749
|
+
case "dynamiczone":
|
|
1750
|
+
const components = attributes2[key]["components"];
|
|
1751
|
+
query[key] = { on: {} };
|
|
1752
|
+
components.forEach((component) => {
|
|
1753
|
+
const componentData2 = strapi.components[component];
|
|
1754
|
+
query[key]["on"][component] = { populate: handleAttributes(componentData2.attributes) };
|
|
1755
|
+
});
|
|
1756
|
+
break;
|
|
1757
|
+
}
|
|
1758
|
+
});
|
|
1759
|
+
return Object.keys(query).length === 0 ? "*" : query;
|
|
1760
|
+
}
|
|
1761
|
+
function populateQueryFromContentType(strapi2, contentType) {
|
|
1762
|
+
const attributes2 = strapi2.contentTypes[contentType]["attributes"];
|
|
1763
|
+
const query = handleAttributes(attributes2);
|
|
1764
|
+
return query;
|
|
1765
|
+
}
|
|
1638
1766
|
const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
1639
1767
|
async adminGetAll() {
|
|
1640
1768
|
const ctx = strapi2.requestContext.get();
|
|
@@ -1688,13 +1816,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1688
1816
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1689
1817
|
where: {
|
|
1690
1818
|
module: "slug",
|
|
1691
|
-
property: [
|
|
1819
|
+
property: [
|
|
1820
|
+
"showDefaultLanguage",
|
|
1821
|
+
"homepageContentId",
|
|
1822
|
+
"homepageContentModel",
|
|
1823
|
+
"homepageSlugStrategy"
|
|
1824
|
+
]
|
|
1692
1825
|
}
|
|
1693
1826
|
});
|
|
1694
1827
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1695
|
-
const homepageContentId = settings.find(
|
|
1696
|
-
|
|
1697
|
-
|
|
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;
|
|
1698
1837
|
let page;
|
|
1699
1838
|
if (homepageSlugStrategy === SLUG_LANGUAGE_STRATEGY && mappedLocales.includes(slug)) {
|
|
1700
1839
|
page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
@@ -1744,9 +1883,10 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1744
1883
|
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1745
1884
|
};
|
|
1746
1885
|
}
|
|
1886
|
+
const query = populateQueryFromContentType(strapi2, page.contentModel);
|
|
1747
1887
|
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1748
1888
|
locale: page.locale,
|
|
1749
|
-
populate:
|
|
1889
|
+
populate: query,
|
|
1750
1890
|
status: "published",
|
|
1751
1891
|
documentId: page.contentId
|
|
1752
1892
|
});
|
|
@@ -1766,6 +1906,15 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1766
1906
|
delete document.createdBy;
|
|
1767
1907
|
delete document.updatedBy;
|
|
1768
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
|
+
});
|
|
1769
1918
|
return {
|
|
1770
1919
|
document,
|
|
1771
1920
|
...page.attributes ? { attributes: page.attributes } : {}
|
|
@@ -1779,13 +1928,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1779
1928
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1780
1929
|
where: {
|
|
1781
1930
|
module: "slug",
|
|
1782
|
-
property: [
|
|
1931
|
+
property: [
|
|
1932
|
+
"showDefaultLanguage",
|
|
1933
|
+
"homepageContentId",
|
|
1934
|
+
"homepageContentModel",
|
|
1935
|
+
"homepageSlugStrategy"
|
|
1936
|
+
]
|
|
1783
1937
|
}
|
|
1784
1938
|
});
|
|
1785
1939
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1786
|
-
const homepageContentId = settings.find(
|
|
1787
|
-
|
|
1788
|
-
|
|
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;
|
|
1789
1949
|
const pages = await strapi2.db.query(config2.uuid.modules.slug).findMany({
|
|
1790
1950
|
where: {
|
|
1791
1951
|
state: "published"
|
|
@@ -1863,13 +2023,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1863
2023
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1864
2024
|
where: {
|
|
1865
2025
|
module: "slug",
|
|
1866
|
-
property: [
|
|
2026
|
+
property: [
|
|
2027
|
+
"showDefaultLanguage",
|
|
2028
|
+
"homepageContentId",
|
|
2029
|
+
"homepageContentModel",
|
|
2030
|
+
"homepageSlugStrategy"
|
|
2031
|
+
]
|
|
1867
2032
|
}
|
|
1868
2033
|
});
|
|
1869
2034
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1870
|
-
const homepageContentId = settings.find(
|
|
1871
|
-
|
|
1872
|
-
|
|
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;
|
|
1873
2044
|
const page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
1874
2045
|
where: {
|
|
1875
2046
|
state: "published",
|
|
@@ -1904,9 +2075,10 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1904
2075
|
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1905
2076
|
};
|
|
1906
2077
|
}
|
|
2078
|
+
const query = populateQueryFromContentType(strapi2, page.contentModel);
|
|
1907
2079
|
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1908
2080
|
locale: page.locale,
|
|
1909
|
-
populate:
|
|
2081
|
+
populate: query,
|
|
1910
2082
|
status: "published",
|
|
1911
2083
|
documentId: page.contentId
|
|
1912
2084
|
});
|
|
@@ -1926,6 +2098,13 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1926
2098
|
delete document.createdBy;
|
|
1927
2099
|
delete document.updatedBy;
|
|
1928
2100
|
document.slug = "";
|
|
2101
|
+
document.breadcrumbs = [
|
|
2102
|
+
{
|
|
2103
|
+
position: 1,
|
|
2104
|
+
name: document.title,
|
|
2105
|
+
item: ""
|
|
2106
|
+
}
|
|
2107
|
+
];
|
|
1929
2108
|
return {
|
|
1930
2109
|
document,
|
|
1931
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,133 @@ 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
|
+
}
|
|
1733
|
+
function handleAttributes(attributes2) {
|
|
1734
|
+
const query = {};
|
|
1735
|
+
Object.keys(attributes2).forEach((key) => {
|
|
1736
|
+
switch (attributes2[key]["type"]) {
|
|
1737
|
+
case "component":
|
|
1738
|
+
const componentData = strapi.components[attributes2[key]["component"]];
|
|
1739
|
+
query[key] = { populate: handleAttributes(componentData.attributes) };
|
|
1740
|
+
break;
|
|
1741
|
+
case "media":
|
|
1742
|
+
query[key] = { populate: "*" };
|
|
1743
|
+
break;
|
|
1744
|
+
case "relation":
|
|
1745
|
+
if (key === "roles" || key === "users" || key === "createdBy" || key === "updatedBy") break;
|
|
1746
|
+
query[key] = key === "localizations" ? { populate: "*" } : { populate: populateQueryFromContentType(strapi, attributes2[key]["target"]) };
|
|
1747
|
+
break;
|
|
1748
|
+
case "dynamiczone":
|
|
1749
|
+
const components = attributes2[key]["components"];
|
|
1750
|
+
query[key] = { on: {} };
|
|
1751
|
+
components.forEach((component) => {
|
|
1752
|
+
const componentData2 = strapi.components[component];
|
|
1753
|
+
query[key]["on"][component] = { populate: handleAttributes(componentData2.attributes) };
|
|
1754
|
+
});
|
|
1755
|
+
break;
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
return Object.keys(query).length === 0 ? "*" : query;
|
|
1759
|
+
}
|
|
1760
|
+
function populateQueryFromContentType(strapi2, contentType) {
|
|
1761
|
+
const attributes2 = strapi2.contentTypes[contentType]["attributes"];
|
|
1762
|
+
const query = handleAttributes(attributes2);
|
|
1763
|
+
return query;
|
|
1764
|
+
}
|
|
1637
1765
|
const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
1638
1766
|
async adminGetAll() {
|
|
1639
1767
|
const ctx = strapi2.requestContext.get();
|
|
@@ -1687,13 +1815,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1687
1815
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1688
1816
|
where: {
|
|
1689
1817
|
module: "slug",
|
|
1690
|
-
property: [
|
|
1818
|
+
property: [
|
|
1819
|
+
"showDefaultLanguage",
|
|
1820
|
+
"homepageContentId",
|
|
1821
|
+
"homepageContentModel",
|
|
1822
|
+
"homepageSlugStrategy"
|
|
1823
|
+
]
|
|
1691
1824
|
}
|
|
1692
1825
|
});
|
|
1693
1826
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1694
|
-
const homepageContentId = settings.find(
|
|
1695
|
-
|
|
1696
|
-
|
|
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;
|
|
1697
1836
|
let page;
|
|
1698
1837
|
if (homepageSlugStrategy === SLUG_LANGUAGE_STRATEGY && mappedLocales.includes(slug)) {
|
|
1699
1838
|
page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
@@ -1743,9 +1882,10 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1743
1882
|
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1744
1883
|
};
|
|
1745
1884
|
}
|
|
1885
|
+
const query = populateQueryFromContentType(strapi2, page.contentModel);
|
|
1746
1886
|
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1747
1887
|
locale: page.locale,
|
|
1748
|
-
populate:
|
|
1888
|
+
populate: query,
|
|
1749
1889
|
status: "published",
|
|
1750
1890
|
documentId: page.contentId
|
|
1751
1891
|
});
|
|
@@ -1765,6 +1905,15 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1765
1905
|
delete document.createdBy;
|
|
1766
1906
|
delete document.updatedBy;
|
|
1767
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
|
+
});
|
|
1768
1917
|
return {
|
|
1769
1918
|
document,
|
|
1770
1919
|
...page.attributes ? { attributes: page.attributes } : {}
|
|
@@ -1778,13 +1927,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1778
1927
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1779
1928
|
where: {
|
|
1780
1929
|
module: "slug",
|
|
1781
|
-
property: [
|
|
1930
|
+
property: [
|
|
1931
|
+
"showDefaultLanguage",
|
|
1932
|
+
"homepageContentId",
|
|
1933
|
+
"homepageContentModel",
|
|
1934
|
+
"homepageSlugStrategy"
|
|
1935
|
+
]
|
|
1782
1936
|
}
|
|
1783
1937
|
});
|
|
1784
1938
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1785
|
-
const homepageContentId = settings.find(
|
|
1786
|
-
|
|
1787
|
-
|
|
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;
|
|
1788
1948
|
const pages = await strapi2.db.query(config2.uuid.modules.slug).findMany({
|
|
1789
1949
|
where: {
|
|
1790
1950
|
state: "published"
|
|
@@ -1862,13 +2022,24 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1862
2022
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1863
2023
|
where: {
|
|
1864
2024
|
module: "slug",
|
|
1865
|
-
property: [
|
|
2025
|
+
property: [
|
|
2026
|
+
"showDefaultLanguage",
|
|
2027
|
+
"homepageContentId",
|
|
2028
|
+
"homepageContentModel",
|
|
2029
|
+
"homepageSlugStrategy"
|
|
2030
|
+
]
|
|
1866
2031
|
}
|
|
1867
2032
|
});
|
|
1868
2033
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1869
|
-
const homepageContentId = settings.find(
|
|
1870
|
-
|
|
1871
|
-
|
|
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;
|
|
1872
2043
|
const page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
1873
2044
|
where: {
|
|
1874
2045
|
state: "published",
|
|
@@ -1903,9 +2074,10 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1903
2074
|
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1904
2075
|
};
|
|
1905
2076
|
}
|
|
2077
|
+
const query = populateQueryFromContentType(strapi2, page.contentModel);
|
|
1906
2078
|
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1907
2079
|
locale: page.locale,
|
|
1908
|
-
populate:
|
|
2080
|
+
populate: query,
|
|
1909
2081
|
status: "published",
|
|
1910
2082
|
documentId: page.contentId
|
|
1911
2083
|
});
|
|
@@ -1925,6 +2097,13 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1925
2097
|
delete document.createdBy;
|
|
1926
2098
|
delete document.updatedBy;
|
|
1927
2099
|
document.slug = "";
|
|
2100
|
+
document.breadcrumbs = [
|
|
2101
|
+
{
|
|
2102
|
+
position: 1,
|
|
2103
|
+
name: document.title,
|
|
2104
|
+
item: ""
|
|
2105
|
+
}
|
|
2106
|
+
];
|
|
1928
2107
|
return {
|
|
1929
2108
|
document,
|
|
1930
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