@littlebox/strapi-suite 1.0.33 → 1.0.34
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/README.md +5 -0
- package/dist/_chunks/{App-BwtvAoMl.js → App-BHSmVWtI.js} +117 -19
- package/dist/_chunks/{App-CXitaGLI.mjs → App-DyjWjB7j.mjs} +118 -20
- package/dist/_chunks/{SlugInput-0Vo-U5cA.js → SlugInput-6ZNFcvBl.js} +2 -2
- package/dist/_chunks/{SlugInput-DvuzCwKx.mjs → SlugInput-Blvf1j9x.mjs} +2 -2
- package/dist/_chunks/{convertToSlug-DGSdTBaK.js → convertToSlug-CTdv5t0Z.js} +1 -1
- package/dist/_chunks/{convertToSlug-CRnBMJHB.mjs → convertToSlug-Cc3NGUTL.mjs} +1 -1
- package/dist/_chunks/{en-Bz6GsXYT.js → en-B02DK8eB.js} +3 -0
- package/dist/_chunks/{en-RUOaam8y.mjs → en-Gbpe0cex.mjs} +3 -0
- package/dist/_chunks/{index-BZqSioMv.js → index-DXJ64IZL.js} +3 -3
- package/dist/_chunks/{index-BBTYu57z.mjs → index-JYGAi1yZ.mjs} +3 -3
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/SlugSettingsModal.d.ts +7 -1
- package/dist/server/index.js +107 -6
- package/dist/server/index.mjs +107 -6
- package/dist/server/src/controllers/index.d.ts +1 -0
- package/dist/server/src/controllers/modules/slug.d.ts +1 -0
- package/dist/server/src/index.d.ts +5 -0
- package/dist/server/src/services/index.d.ts +4 -0
- package/dist/server/src/services/modules/slug.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -200,6 +200,11 @@ GET /api/littlebox-strapi-suite/modules/pages?slug=<SLUG>
|
|
|
200
200
|
```
|
|
201
201
|
**Note**: The default language won't show up in the URL slug if the `SHOW LANGUAGE SLUG` setting is turned off in the slug module settings (see screenshot above).
|
|
202
202
|
|
|
203
|
+
Using the slug module settings (as shown in the screenshot above), you can choose which content will be set as the homepage. Then, just call the API to get the data:
|
|
204
|
+
```
|
|
205
|
+
GET /api/littlebox-strapi-suite/modules/pages/home?properties=attributes
|
|
206
|
+
```
|
|
207
|
+
|
|
203
208
|
|
|
204
209
|
|
|
205
210
|
|
|
@@ -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-DXJ64IZL.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-CTdv5t0Z.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");
|
|
@@ -930,27 +930,56 @@ const ConfirmModal = ({ open, title, text, confirm, cancel }) => {
|
|
|
930
930
|
] }) }) })
|
|
931
931
|
] }) }) });
|
|
932
932
|
};
|
|
933
|
-
const
|
|
933
|
+
const BoxInput$7 = styled__default.default(designSystem.Box)`
|
|
934
|
+
& > div {
|
|
935
|
+
width: 100%;
|
|
936
|
+
}
|
|
937
|
+
`;
|
|
938
|
+
const SlugSettingsModal = ({ open, close, defaultLocale }) => {
|
|
934
939
|
const [module2, setModule] = React.useState(index.config.uuid.modules.slug);
|
|
935
940
|
const [hidden, setHidden] = React.useState(true);
|
|
936
|
-
const [
|
|
941
|
+
const [showDefaultLanguage, setShowDefaultLanguage] = React.useState(true);
|
|
942
|
+
const [selectedContent, setSelectedContent] = React.useState();
|
|
943
|
+
const [pages, setPages] = React.useState([]);
|
|
944
|
+
const [saveInProgress, setSaveInProgress] = React.useState(false);
|
|
937
945
|
const { formatMessage } = reactIntl.useIntl();
|
|
938
946
|
const settings = useSettings();
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
+
function updateSetting(property, value) {
|
|
948
|
+
const updateSetting2 = new UpdateSetting();
|
|
949
|
+
updateSetting2.execute({ property, module: module2, value });
|
|
950
|
+
}
|
|
951
|
+
function handleChangeSelectedContent(value) {
|
|
952
|
+
const page = pages.find((page2) => page2.id == value);
|
|
953
|
+
setSelectedContent(page);
|
|
954
|
+
}
|
|
955
|
+
function save() {
|
|
956
|
+
updateSetting("showDefaultLanguage", showDefaultLanguage);
|
|
957
|
+
updateSetting("homepageContentId", selectedContent?.contentId);
|
|
958
|
+
updateSetting("homepageContentModel", selectedContent?.contentModel);
|
|
959
|
+
close();
|
|
960
|
+
}
|
|
961
|
+
async function fetchSlugs() {
|
|
962
|
+
const fetchSlugs2 = new index.FetchSlugs();
|
|
963
|
+
const outputFetchSlugs = await fetchSlugs2.execute({ locale: defaultLocale.code });
|
|
964
|
+
setPages(outputFetchSlugs);
|
|
947
965
|
}
|
|
966
|
+
React.useEffect(() => {
|
|
967
|
+
if (defaultLocale) {
|
|
968
|
+
fetchSlugs();
|
|
969
|
+
}
|
|
970
|
+
}, [defaultLocale]);
|
|
948
971
|
React.useEffect(() => {
|
|
949
972
|
setHidden(!open);
|
|
950
973
|
}, [open]);
|
|
951
974
|
React.useEffect(() => {
|
|
952
|
-
|
|
953
|
-
|
|
975
|
+
const currentShowDefaultLanguage = settings.provide("slug").showDefaultLanguage;
|
|
976
|
+
setShowDefaultLanguage(currentShowDefaultLanguage);
|
|
977
|
+
}, []);
|
|
978
|
+
React.useEffect(() => {
|
|
979
|
+
const currentHomePage = settings.provide("slug").homepageContentId;
|
|
980
|
+
const page = pages.find((page2) => page2.contentId == currentHomePage);
|
|
981
|
+
setSelectedContent(page);
|
|
982
|
+
}, [pages]);
|
|
954
983
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hidden && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { defaultOpen: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
|
955
984
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { style: { textAlign: "left" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { style: { width: "100%", justifyContent: "space-between" }, children: [
|
|
956
985
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
|
|
@@ -966,14 +995,47 @@ const SlugSettingsModal = ({ open, close }) => {
|
|
|
966
995
|
),
|
|
967
996
|
defaultMessage: "Show language slug"
|
|
968
997
|
}) }) }),
|
|
969
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { paddingBottom: "
|
|
998
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { paddingBottom: "5px", color: "#a5a5ba", display: "flex" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", children: formatMessage({
|
|
970
999
|
id: index.getTranslation(
|
|
971
1000
|
`module.${module2}.modal.settings.input.default-language.description`
|
|
972
1001
|
),
|
|
973
1002
|
defaultMessage: "Show language slug for default language in site url"
|
|
974
1003
|
}) }) }),
|
|
975
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
976
|
-
|
|
1004
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1005
|
+
designSystem.Toggle,
|
|
1006
|
+
{
|
|
1007
|
+
onLabel: "True",
|
|
1008
|
+
offLabel: "False",
|
|
1009
|
+
checked: showDefaultLanguage,
|
|
1010
|
+
onChange: (e) => setShowDefaultLanguage(e.target.checked)
|
|
1011
|
+
}
|
|
1012
|
+
),
|
|
1013
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { paddingBottom: "5px", paddingTop: "24px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
|
|
1014
|
+
id: index.getTranslation(`module.${module2}.modal.settings.input.homepage.title`),
|
|
1015
|
+
defaultMessage: "Home page"
|
|
1016
|
+
}) }) }),
|
|
1017
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { paddingBottom: "5px", color: "#a5a5ba", display: "flex" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", children: formatMessage({
|
|
1018
|
+
id: index.getTranslation(
|
|
1019
|
+
`module.${module2}.modal.settings.input.homepage.description`
|
|
1020
|
+
),
|
|
1021
|
+
defaultMessage: "The content that will be rendered as the homepage"
|
|
1022
|
+
}) }) }),
|
|
1023
|
+
/* @__PURE__ */ jsxRuntime.jsx(BoxInput$7, { style: { flex: 1, display: "flex", width: "100%", marginRight: "10px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1024
|
+
designSystem.SingleSelect,
|
|
1025
|
+
{
|
|
1026
|
+
onChange: (value) => handleChangeSelectedContent(value),
|
|
1027
|
+
value: selectedContent?.id,
|
|
1028
|
+
children: pages.map((page, index2) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: page.id, children: page.contentTitle }, index2))
|
|
1029
|
+
}
|
|
1030
|
+
) })
|
|
1031
|
+
] }) }),
|
|
1032
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { style: { justifyContent: "end" }, children: [
|
|
1033
|
+
saveInProgress && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true }),
|
|
1034
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { style: { marginRight: "5px" }, onClick: save, disabled: saveInProgress, children: formatMessage({
|
|
1035
|
+
id: index.getTranslation(`module.${module2}.modal.settings.button.save`),
|
|
1036
|
+
defaultMessage: "Save"
|
|
1037
|
+
}) })
|
|
1038
|
+
] })
|
|
977
1039
|
] }) }) });
|
|
978
1040
|
};
|
|
979
1041
|
const SlugSettingsPage = () => {
|
|
@@ -982,11 +1044,13 @@ const SlugSettingsPage = () => {
|
|
|
982
1044
|
const [filteredRecords, setFilteredRecords] = React.useState([]);
|
|
983
1045
|
const [i18nLocales, setI18nLocales] = React.useState([]);
|
|
984
1046
|
const [currentI18nLocale, setCurrentI18nLocale] = React.useState();
|
|
1047
|
+
const [defaultLocale, setDefaultLocale] = React.useState();
|
|
985
1048
|
const [fetchInProgress, setFetchInProgress] = React.useState(true);
|
|
986
1049
|
const [showConfirmModal, setShowConfirmModal] = React.useState(false);
|
|
987
1050
|
const [showSettingsModal, setShowSettingsModal] = React.useState(false);
|
|
988
1051
|
const [selectedRecords, setSelectedRecords] = React.useState([]);
|
|
989
1052
|
const [searchTerm, setSearchTerm] = React.useState("");
|
|
1053
|
+
const [currentHomePage, setCurrentHomePage] = React.useState();
|
|
990
1054
|
const { formatMessage } = reactIntl.useIntl();
|
|
991
1055
|
const settings = useSettings();
|
|
992
1056
|
async function toggleState(value) {
|
|
@@ -1007,7 +1071,9 @@ const SlugSettingsPage = () => {
|
|
|
1007
1071
|
async function fetchLocales() {
|
|
1008
1072
|
const fetchLocales2 = new convertToSlug.FetchLocales();
|
|
1009
1073
|
const fetchLocalesOutput = await fetchLocales2.execute();
|
|
1074
|
+
const defaultLocale2 = fetchLocalesOutput.find((locale) => locale.isDefault);
|
|
1010
1075
|
setI18nLocales(fetchLocalesOutput);
|
|
1076
|
+
setDefaultLocale(defaultLocale2);
|
|
1011
1077
|
}
|
|
1012
1078
|
async function fetchRecords() {
|
|
1013
1079
|
setFetchInProgress(true);
|
|
@@ -1051,6 +1117,10 @@ const SlugSettingsPage = () => {
|
|
|
1051
1117
|
const parent = records.find((record) => record.contentId === parentId);
|
|
1052
1118
|
return parent?.contentTitle;
|
|
1053
1119
|
}
|
|
1120
|
+
function getCurrentHomePage() {
|
|
1121
|
+
const currentHomePage2 = settings.provide("slug").homepageContentId;
|
|
1122
|
+
setCurrentHomePage(currentHomePage2);
|
|
1123
|
+
}
|
|
1054
1124
|
React.useEffect(() => {
|
|
1055
1125
|
const timer = setTimeout(() => {
|
|
1056
1126
|
if (records.length > 0) {
|
|
@@ -1071,6 +1141,9 @@ const SlugSettingsPage = () => {
|
|
|
1071
1141
|
fetchRecords();
|
|
1072
1142
|
}
|
|
1073
1143
|
}, [currentI18nLocale]);
|
|
1144
|
+
React.useEffect(() => {
|
|
1145
|
+
getCurrentHomePage();
|
|
1146
|
+
}, [settings]);
|
|
1074
1147
|
React.useEffect(() => {
|
|
1075
1148
|
fetchLocales();
|
|
1076
1149
|
}, []);
|
|
@@ -1190,7 +1263,25 @@ const SlugSettingsPage = () => {
|
|
|
1190
1263
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: entry.id }) }),
|
|
1191
1264
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: entry.locale }) }),
|
|
1192
1265
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: entry.slug }) }),
|
|
1193
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.
|
|
1266
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { display: "flex", alignItems: "center" }, children: [
|
|
1267
|
+
entry.contentId === currentHomePage && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1268
|
+
designSystem.Box,
|
|
1269
|
+
{
|
|
1270
|
+
style: {
|
|
1271
|
+
display: "flex",
|
|
1272
|
+
alignItems: "center",
|
|
1273
|
+
justifyContent: "center",
|
|
1274
|
+
backgroundColor: "#7b79ff",
|
|
1275
|
+
color: "#fff",
|
|
1276
|
+
borderRadius: "4px",
|
|
1277
|
+
padding: "3px 8px",
|
|
1278
|
+
marginRight: "10px"
|
|
1279
|
+
},
|
|
1280
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Homepage" })
|
|
1281
|
+
}
|
|
1282
|
+
),
|
|
1283
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: entry.contentTitle })
|
|
1284
|
+
] }) }),
|
|
1194
1285
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "neutral800", children: [
|
|
1195
1286
|
!entry.parentContentId && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "--" }),
|
|
1196
1287
|
entry.parentContentId && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1288,7 +1379,14 @@ const SlugSettingsPage = () => {
|
|
|
1288
1379
|
}
|
|
1289
1380
|
}
|
|
1290
1381
|
),
|
|
1291
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1382
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1383
|
+
SlugSettingsModal,
|
|
1384
|
+
{
|
|
1385
|
+
defaultLocale,
|
|
1386
|
+
open: showSettingsModal,
|
|
1387
|
+
close: () => setShowSettingsModal(false)
|
|
1388
|
+
}
|
|
1389
|
+
)
|
|
1292
1390
|
]
|
|
1293
1391
|
}
|
|
1294
1392
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
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
|
-
import { Box, Loader, Main, Typography, Button, Flex, Breadcrumbs, Crumb, CrumbLink, CardBody, CardContent, CardTitle, CardBadge, CardSubtitle, Card as Card$1, Dialog, IconButton, Toggle,
|
|
5
|
-
import { R as Registry, F as FetchSettings, g as getTranslation, c as config, a as FetchSlugs, f as fetchTemplates } from "./index-
|
|
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, a as FetchSlugs, f as fetchTemplates } from "./index-JYGAi1yZ.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-Cc3NGUTL.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";
|
|
@@ -925,27 +925,56 @@ const ConfirmModal = ({ open, title, text, confirm, cancel }) => {
|
|
|
925
925
|
] }) }) })
|
|
926
926
|
] }) }) });
|
|
927
927
|
};
|
|
928
|
-
const
|
|
928
|
+
const BoxInput$7 = styled(Box)`
|
|
929
|
+
& > div {
|
|
930
|
+
width: 100%;
|
|
931
|
+
}
|
|
932
|
+
`;
|
|
933
|
+
const SlugSettingsModal = ({ open, close, defaultLocale }) => {
|
|
929
934
|
const [module, setModule] = useState(config.uuid.modules.slug);
|
|
930
935
|
const [hidden, setHidden] = useState(true);
|
|
931
|
-
const [
|
|
936
|
+
const [showDefaultLanguage, setShowDefaultLanguage] = useState(true);
|
|
937
|
+
const [selectedContent, setSelectedContent] = useState();
|
|
938
|
+
const [pages, setPages] = useState([]);
|
|
939
|
+
const [saveInProgress, setSaveInProgress] = useState(false);
|
|
932
940
|
const { formatMessage } = useIntl();
|
|
933
941
|
const settings = useSettings();
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
+
function updateSetting(property, value) {
|
|
943
|
+
const updateSetting2 = new UpdateSetting();
|
|
944
|
+
updateSetting2.execute({ property, module, value });
|
|
945
|
+
}
|
|
946
|
+
function handleChangeSelectedContent(value) {
|
|
947
|
+
const page = pages.find((page2) => page2.id == value);
|
|
948
|
+
setSelectedContent(page);
|
|
949
|
+
}
|
|
950
|
+
function save() {
|
|
951
|
+
updateSetting("showDefaultLanguage", showDefaultLanguage);
|
|
952
|
+
updateSetting("homepageContentId", selectedContent?.contentId);
|
|
953
|
+
updateSetting("homepageContentModel", selectedContent?.contentModel);
|
|
954
|
+
close();
|
|
955
|
+
}
|
|
956
|
+
async function fetchSlugs() {
|
|
957
|
+
const fetchSlugs2 = new FetchSlugs();
|
|
958
|
+
const outputFetchSlugs = await fetchSlugs2.execute({ locale: defaultLocale.code });
|
|
959
|
+
setPages(outputFetchSlugs);
|
|
942
960
|
}
|
|
961
|
+
useEffect(() => {
|
|
962
|
+
if (defaultLocale) {
|
|
963
|
+
fetchSlugs();
|
|
964
|
+
}
|
|
965
|
+
}, [defaultLocale]);
|
|
943
966
|
useEffect(() => {
|
|
944
967
|
setHidden(!open);
|
|
945
968
|
}, [open]);
|
|
946
969
|
useEffect(() => {
|
|
947
|
-
|
|
948
|
-
|
|
970
|
+
const currentShowDefaultLanguage = settings.provide("slug").showDefaultLanguage;
|
|
971
|
+
setShowDefaultLanguage(currentShowDefaultLanguage);
|
|
972
|
+
}, []);
|
|
973
|
+
useEffect(() => {
|
|
974
|
+
const currentHomePage = settings.provide("slug").homepageContentId;
|
|
975
|
+
const page = pages.find((page2) => page2.contentId == currentHomePage);
|
|
976
|
+
setSelectedContent(page);
|
|
977
|
+
}, [pages]);
|
|
949
978
|
return /* @__PURE__ */ jsx(Fragment, { children: !hidden && /* @__PURE__ */ jsx(Dialog.Root, { defaultOpen: true, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
|
950
979
|
/* @__PURE__ */ jsx(Dialog.Header, { style: { textAlign: "left" }, children: /* @__PURE__ */ jsxs(Flex, { style: { width: "100%", justifyContent: "space-between" }, children: [
|
|
951
980
|
/* @__PURE__ */ jsx(Typography, { variant: "omega", children: formatMessage({
|
|
@@ -961,14 +990,47 @@ const SlugSettingsModal = ({ open, close }) => {
|
|
|
961
990
|
),
|
|
962
991
|
defaultMessage: "Show language slug"
|
|
963
992
|
}) }) }),
|
|
964
|
-
/* @__PURE__ */ jsx("span", { style: { paddingBottom: "
|
|
993
|
+
/* @__PURE__ */ jsx("span", { style: { paddingBottom: "5px", color: "#a5a5ba", display: "flex" }, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", children: formatMessage({
|
|
965
994
|
id: getTranslation(
|
|
966
995
|
`module.${module}.modal.settings.input.default-language.description`
|
|
967
996
|
),
|
|
968
997
|
defaultMessage: "Show language slug for default language in site url"
|
|
969
998
|
}) }) }),
|
|
970
|
-
/* @__PURE__ */ jsx(
|
|
971
|
-
|
|
999
|
+
/* @__PURE__ */ jsx(
|
|
1000
|
+
Toggle,
|
|
1001
|
+
{
|
|
1002
|
+
onLabel: "True",
|
|
1003
|
+
offLabel: "False",
|
|
1004
|
+
checked: showDefaultLanguage,
|
|
1005
|
+
onChange: (e) => setShowDefaultLanguage(e.target.checked)
|
|
1006
|
+
}
|
|
1007
|
+
),
|
|
1008
|
+
/* @__PURE__ */ jsx("span", { style: { paddingBottom: "5px", paddingTop: "24px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
|
|
1009
|
+
id: getTranslation(`module.${module}.modal.settings.input.homepage.title`),
|
|
1010
|
+
defaultMessage: "Home page"
|
|
1011
|
+
}) }) }),
|
|
1012
|
+
/* @__PURE__ */ jsx("span", { style: { paddingBottom: "5px", color: "#a5a5ba", display: "flex" }, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", children: formatMessage({
|
|
1013
|
+
id: getTranslation(
|
|
1014
|
+
`module.${module}.modal.settings.input.homepage.description`
|
|
1015
|
+
),
|
|
1016
|
+
defaultMessage: "The content that will be rendered as the homepage"
|
|
1017
|
+
}) }) }),
|
|
1018
|
+
/* @__PURE__ */ jsx(BoxInput$7, { style: { flex: 1, display: "flex", width: "100%", marginRight: "10px" }, children: /* @__PURE__ */ jsx(
|
|
1019
|
+
SingleSelect,
|
|
1020
|
+
{
|
|
1021
|
+
onChange: (value) => handleChangeSelectedContent(value),
|
|
1022
|
+
value: selectedContent?.id,
|
|
1023
|
+
children: pages.map((page, index) => /* @__PURE__ */ jsx(SingleSelectOption, { value: page.id, children: page.contentTitle }, index))
|
|
1024
|
+
}
|
|
1025
|
+
) })
|
|
1026
|
+
] }) }),
|
|
1027
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { style: { justifyContent: "end" }, children: [
|
|
1028
|
+
saveInProgress && /* @__PURE__ */ jsx(Loader, { small: true }),
|
|
1029
|
+
/* @__PURE__ */ jsx(Button, { style: { marginRight: "5px" }, onClick: save, disabled: saveInProgress, children: formatMessage({
|
|
1030
|
+
id: getTranslation(`module.${module}.modal.settings.button.save`),
|
|
1031
|
+
defaultMessage: "Save"
|
|
1032
|
+
}) })
|
|
1033
|
+
] })
|
|
972
1034
|
] }) }) });
|
|
973
1035
|
};
|
|
974
1036
|
const SlugSettingsPage = () => {
|
|
@@ -977,11 +1039,13 @@ const SlugSettingsPage = () => {
|
|
|
977
1039
|
const [filteredRecords, setFilteredRecords] = useState([]);
|
|
978
1040
|
const [i18nLocales, setI18nLocales] = useState([]);
|
|
979
1041
|
const [currentI18nLocale, setCurrentI18nLocale] = useState();
|
|
1042
|
+
const [defaultLocale, setDefaultLocale] = useState();
|
|
980
1043
|
const [fetchInProgress, setFetchInProgress] = useState(true);
|
|
981
1044
|
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
|
982
1045
|
const [showSettingsModal, setShowSettingsModal] = useState(false);
|
|
983
1046
|
const [selectedRecords, setSelectedRecords] = useState([]);
|
|
984
1047
|
const [searchTerm, setSearchTerm] = useState("");
|
|
1048
|
+
const [currentHomePage, setCurrentHomePage] = useState();
|
|
985
1049
|
const { formatMessage } = useIntl();
|
|
986
1050
|
const settings = useSettings();
|
|
987
1051
|
async function toggleState(value) {
|
|
@@ -1002,7 +1066,9 @@ const SlugSettingsPage = () => {
|
|
|
1002
1066
|
async function fetchLocales() {
|
|
1003
1067
|
const fetchLocales2 = new FetchLocales();
|
|
1004
1068
|
const fetchLocalesOutput = await fetchLocales2.execute();
|
|
1069
|
+
const defaultLocale2 = fetchLocalesOutput.find((locale) => locale.isDefault);
|
|
1005
1070
|
setI18nLocales(fetchLocalesOutput);
|
|
1071
|
+
setDefaultLocale(defaultLocale2);
|
|
1006
1072
|
}
|
|
1007
1073
|
async function fetchRecords() {
|
|
1008
1074
|
setFetchInProgress(true);
|
|
@@ -1046,6 +1112,10 @@ const SlugSettingsPage = () => {
|
|
|
1046
1112
|
const parent = records.find((record) => record.contentId === parentId);
|
|
1047
1113
|
return parent?.contentTitle;
|
|
1048
1114
|
}
|
|
1115
|
+
function getCurrentHomePage() {
|
|
1116
|
+
const currentHomePage2 = settings.provide("slug").homepageContentId;
|
|
1117
|
+
setCurrentHomePage(currentHomePage2);
|
|
1118
|
+
}
|
|
1049
1119
|
useEffect(() => {
|
|
1050
1120
|
const timer = setTimeout(() => {
|
|
1051
1121
|
if (records.length > 0) {
|
|
@@ -1066,6 +1136,9 @@ const SlugSettingsPage = () => {
|
|
|
1066
1136
|
fetchRecords();
|
|
1067
1137
|
}
|
|
1068
1138
|
}, [currentI18nLocale]);
|
|
1139
|
+
useEffect(() => {
|
|
1140
|
+
getCurrentHomePage();
|
|
1141
|
+
}, [settings]);
|
|
1069
1142
|
useEffect(() => {
|
|
1070
1143
|
fetchLocales();
|
|
1071
1144
|
}, []);
|
|
@@ -1185,7 +1258,25 @@ const SlugSettingsPage = () => {
|
|
|
1185
1258
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: entry.id }) }),
|
|
1186
1259
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: entry.locale }) }),
|
|
1187
1260
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: entry.slug }) }),
|
|
1188
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */
|
|
1261
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Box, { style: { display: "flex", alignItems: "center" }, children: [
|
|
1262
|
+
entry.contentId === currentHomePage && /* @__PURE__ */ jsx(
|
|
1263
|
+
Box,
|
|
1264
|
+
{
|
|
1265
|
+
style: {
|
|
1266
|
+
display: "flex",
|
|
1267
|
+
alignItems: "center",
|
|
1268
|
+
justifyContent: "center",
|
|
1269
|
+
backgroundColor: "#7b79ff",
|
|
1270
|
+
color: "#fff",
|
|
1271
|
+
borderRadius: "4px",
|
|
1272
|
+
padding: "3px 8px",
|
|
1273
|
+
marginRight: "10px"
|
|
1274
|
+
},
|
|
1275
|
+
children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Homepage" })
|
|
1276
|
+
}
|
|
1277
|
+
),
|
|
1278
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: entry.contentTitle })
|
|
1279
|
+
] }) }),
|
|
1189
1280
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Typography, { textColor: "neutral800", children: [
|
|
1190
1281
|
!entry.parentContentId && /* @__PURE__ */ jsx(Fragment, { children: "--" }),
|
|
1191
1282
|
entry.parentContentId && /* @__PURE__ */ jsx(
|
|
@@ -1283,7 +1374,14 @@ const SlugSettingsPage = () => {
|
|
|
1283
1374
|
}
|
|
1284
1375
|
}
|
|
1285
1376
|
),
|
|
1286
|
-
/* @__PURE__ */ jsx(
|
|
1377
|
+
/* @__PURE__ */ jsx(
|
|
1378
|
+
SlugSettingsModal,
|
|
1379
|
+
{
|
|
1380
|
+
defaultLocale,
|
|
1381
|
+
open: showSettingsModal,
|
|
1382
|
+
close: () => setShowSettingsModal(false)
|
|
1383
|
+
}
|
|
1384
|
+
)
|
|
1287
1385
|
]
|
|
1288
1386
|
}
|
|
1289
1387
|
);
|
|
@@ -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-DXJ64IZL.js");
|
|
12
|
+
const convertToSlug = require("./convertToSlug-CTdv5t0Z.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;
|
|
@@ -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, b as PluginIcon, g as getTranslation, c as config, d 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, b as PluginIcon, g as getTranslation, c as config, d as FetchModuleSettings } from "./index-JYGAi1yZ.mjs";
|
|
10
|
+
import { c as convertToSlug, F as FetchLocales } from "./convertToSlug-Cc3NGUTL.mjs";
|
|
11
11
|
const BoxInput = styled(Box)`
|
|
12
12
|
& > div {
|
|
13
13
|
width: 100%;
|
|
@@ -55,6 +55,9 @@ const en = {
|
|
|
55
55
|
"littlebox-strapi-suite.module.slug.modal.settings.title": "Settings",
|
|
56
56
|
"littlebox-strapi-suite.module.slug.modal.settings.input.default-language.title": "Show language slug",
|
|
57
57
|
"littlebox-strapi-suite.module.slug.modal.settings.input.default-language.description": "Show language slug for default language in site url",
|
|
58
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage.title": "Home page",
|
|
59
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage.description": "The content that will be rendered as the homepage",
|
|
60
|
+
"littlebox-strapi-suite.module.slug.modal.settings.button.save": "Save",
|
|
58
61
|
"littlebox-strapi-suite.module.attribute.name": "Attribute",
|
|
59
62
|
"littlebox-strapi-suite.module.attribute.description": "Effortlessly customize any page with simple and flexible attribute options.",
|
|
60
63
|
"littlebox-strapi-suite.module.attribute.panel.title": "Page Attributes",
|
|
@@ -53,6 +53,9 @@ const en = {
|
|
|
53
53
|
"littlebox-strapi-suite.module.slug.modal.settings.title": "Settings",
|
|
54
54
|
"littlebox-strapi-suite.module.slug.modal.settings.input.default-language.title": "Show language slug",
|
|
55
55
|
"littlebox-strapi-suite.module.slug.modal.settings.input.default-language.description": "Show language slug for default language in site url",
|
|
56
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage.title": "Home page",
|
|
57
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage.description": "The content that will be rendered as the homepage",
|
|
58
|
+
"littlebox-strapi-suite.module.slug.modal.settings.button.save": "Save",
|
|
56
59
|
"littlebox-strapi-suite.module.attribute.name": "Attribute",
|
|
57
60
|
"littlebox-strapi-suite.module.attribute.description": "Effortlessly customize any page with simple and flexible attribute options.",
|
|
58
61
|
"littlebox-strapi-suite.module.attribute.panel.title": "Page Attributes",
|
|
@@ -3304,7 +3304,7 @@ const index = {
|
|
|
3304
3304
|
defaultMessage: config.pluginId
|
|
3305
3305
|
},
|
|
3306
3306
|
position: 999,
|
|
3307
|
-
Component: () => Promise.resolve().then(() => require("./App-
|
|
3307
|
+
Component: () => Promise.resolve().then(() => require("./App-BHSmVWtI.js"))
|
|
3308
3308
|
});
|
|
3309
3309
|
app.customFields.register({
|
|
3310
3310
|
name: "ltbslug",
|
|
@@ -3322,7 +3322,7 @@ const index = {
|
|
|
3322
3322
|
components: {
|
|
3323
3323
|
Input: async () => Promise.resolve().then(() => require(
|
|
3324
3324
|
/* webpackChunkName: "input-slug-component" */
|
|
3325
|
-
"./SlugInput-
|
|
3325
|
+
"./SlugInput-6ZNFcvBl.js"
|
|
3326
3326
|
))
|
|
3327
3327
|
},
|
|
3328
3328
|
options: {
|
|
@@ -3374,7 +3374,7 @@ const index = {
|
|
|
3374
3374
|
return Promise.all(
|
|
3375
3375
|
locales.map(async (locale) => {
|
|
3376
3376
|
try {
|
|
3377
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => Promise.resolve().then(() => require("./en-
|
|
3377
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => Promise.resolve().then(() => require("./en-B02DK8eB.js")) }), `./core/translations/${locale}.json`, 4);
|
|
3378
3378
|
return { data, locale };
|
|
3379
3379
|
} catch {
|
|
3380
3380
|
return { data: {}, locale };
|
|
@@ -3301,7 +3301,7 @@ const index = {
|
|
|
3301
3301
|
defaultMessage: config.pluginId
|
|
3302
3302
|
},
|
|
3303
3303
|
position: 999,
|
|
3304
|
-
Component: () => import("./App-
|
|
3304
|
+
Component: () => import("./App-DyjWjB7j.mjs")
|
|
3305
3305
|
});
|
|
3306
3306
|
app.customFields.register({
|
|
3307
3307
|
name: "ltbslug",
|
|
@@ -3319,7 +3319,7 @@ const index = {
|
|
|
3319
3319
|
components: {
|
|
3320
3320
|
Input: async () => import(
|
|
3321
3321
|
/* webpackChunkName: "input-slug-component" */
|
|
3322
|
-
"./SlugInput-
|
|
3322
|
+
"./SlugInput-Blvf1j9x.mjs"
|
|
3323
3323
|
)
|
|
3324
3324
|
},
|
|
3325
3325
|
options: {
|
|
@@ -3371,7 +3371,7 @@ const index = {
|
|
|
3371
3371
|
return Promise.all(
|
|
3372
3372
|
locales.map(async (locale) => {
|
|
3373
3373
|
try {
|
|
3374
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => import("./en-
|
|
3374
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => import("./en-Gbpe0cex.mjs") }), `./core/translations/${locale}.json`, 4);
|
|
3375
3375
|
return { data, locale };
|
|
3376
3376
|
} catch {
|
|
3377
3377
|
return { data: {}, locale };
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { Output as OutputFetchLocales } from '../core/usecases/fetchLocales';
|
|
2
|
+
interface Props {
|
|
3
|
+
defaultLocale: OutputFetchLocales;
|
|
4
|
+
open: boolean;
|
|
5
|
+
close: () => void;
|
|
6
|
+
}
|
|
7
|
+
declare const SlugSettingsModal: ({ open, close, defaultLocale }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
2
8
|
export default SlugSettingsModal;
|
package/dist/server/index.js
CHANGED
|
@@ -394,8 +394,8 @@ async function deleteAttributes(event, config2) {
|
|
|
394
394
|
await strapi.db.query(config2.uuid.modules.attribute).updateMany(updateManyWhere);
|
|
395
395
|
}
|
|
396
396
|
const bootstrap = async ({ strapi: strapi2 }) => {
|
|
397
|
+
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
397
398
|
try {
|
|
398
|
-
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
399
399
|
await strapi2.db.query(config2.uuid.app.setting).createMany({
|
|
400
400
|
data: [
|
|
401
401
|
{
|
|
@@ -445,7 +445,25 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
445
445
|
} catch (e) {
|
|
446
446
|
}
|
|
447
447
|
try {
|
|
448
|
-
|
|
448
|
+
await strapi2.db.query(config2.uuid.app.setting).createMany({
|
|
449
|
+
data: [
|
|
450
|
+
{
|
|
451
|
+
module: "slug",
|
|
452
|
+
property: "homepageContentId",
|
|
453
|
+
type: "string",
|
|
454
|
+
value: null
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
module: "slug",
|
|
458
|
+
property: "homepageContentModel",
|
|
459
|
+
type: "string",
|
|
460
|
+
value: null
|
|
461
|
+
}
|
|
462
|
+
]
|
|
463
|
+
});
|
|
464
|
+
} catch (e) {
|
|
465
|
+
}
|
|
466
|
+
try {
|
|
449
467
|
await strapi2.db.query(config2.uuid.modules.template).createMany({
|
|
450
468
|
data: [
|
|
451
469
|
{
|
|
@@ -1088,6 +1106,9 @@ const SlugModuleController = ({ strapi: strapi2 }) => ({
|
|
|
1088
1106
|
const ctx = strapi2.requestContext.get();
|
|
1089
1107
|
const service = strapi2.plugin(PLUGIN_ID).service("SlugModuleService");
|
|
1090
1108
|
return ctx.query.slug ? await service.getPage() : await service.getPages();
|
|
1109
|
+
},
|
|
1110
|
+
async getHomePage() {
|
|
1111
|
+
return await strapi2.plugin(PLUGIN_ID).service("SlugModuleService").getHomePage();
|
|
1091
1112
|
}
|
|
1092
1113
|
});
|
|
1093
1114
|
const AttributeModuleController = ({ strapi: strapi2 }) => ({
|
|
@@ -1241,6 +1262,16 @@ const contentAPIRoutes = [
|
|
|
1241
1262
|
auth: false
|
|
1242
1263
|
}
|
|
1243
1264
|
},
|
|
1265
|
+
{
|
|
1266
|
+
method: "GET",
|
|
1267
|
+
path: "/modules/pages/home",
|
|
1268
|
+
handler: "SlugModuleController.getHomePage",
|
|
1269
|
+
config: {
|
|
1270
|
+
middlewares: [`plugin::${PLUGIN_ID}.check-module-is-active`],
|
|
1271
|
+
policies: ["check-api-token"],
|
|
1272
|
+
auth: false
|
|
1273
|
+
}
|
|
1274
|
+
},
|
|
1244
1275
|
{
|
|
1245
1276
|
method: "GET",
|
|
1246
1277
|
path: "/modules/menus",
|
|
@@ -1694,20 +1725,28 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1694
1725
|
const properties = ctx.query.properties;
|
|
1695
1726
|
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
1696
1727
|
const defaultLocale = await strapi2.plugin("i18n").service("locales").getDefaultLocale();
|
|
1697
|
-
const
|
|
1728
|
+
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1698
1729
|
where: {
|
|
1699
1730
|
module: "slug",
|
|
1700
|
-
property: "showDefaultLanguage"
|
|
1731
|
+
property: ["showDefaultLanguage", "homepageContentId", "homepageContentModel"]
|
|
1701
1732
|
}
|
|
1702
1733
|
});
|
|
1703
|
-
const showDefaultLanguage = setting.value === "true";
|
|
1734
|
+
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1735
|
+
const homepageContentId = settings.find((setting) => setting.property === "homepageContentId").value;
|
|
1736
|
+
settings.find((setting) => setting.property === "homepageContentModel").value;
|
|
1704
1737
|
const pages = await strapi2.db.query(config2.uuid.modules.slug).findMany({
|
|
1705
1738
|
where: {
|
|
1706
1739
|
state: "published"
|
|
1707
1740
|
}
|
|
1708
1741
|
});
|
|
1709
1742
|
pages.forEach((page) => {
|
|
1710
|
-
|
|
1743
|
+
if (homepageContentId === page.contentId && defaultLocale === page.locale) {
|
|
1744
|
+
page.fullSlug = "";
|
|
1745
|
+
} else if (homepageContentId === page.contentId && defaultLocale !== page.locale) {
|
|
1746
|
+
page.fullSlug = page.locale;
|
|
1747
|
+
} else {
|
|
1748
|
+
page.fullSlug = buildFullSlug({ pages, page, defaultLocale, showDefaultLanguage });
|
|
1749
|
+
}
|
|
1711
1750
|
});
|
|
1712
1751
|
if (properties && properties.includes("attributes")) {
|
|
1713
1752
|
for (const page of pages) {
|
|
@@ -1740,6 +1779,68 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1740
1779
|
...page.attributes ? { attributes: page.attributes } : {}
|
|
1741
1780
|
}));
|
|
1742
1781
|
return mappedPages;
|
|
1782
|
+
},
|
|
1783
|
+
async getHomePage() {
|
|
1784
|
+
const ctx = strapi2.requestContext.get();
|
|
1785
|
+
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
1786
|
+
const defaultLocale = await strapi2.plugin("i18n").service("locales").getDefaultLocale();
|
|
1787
|
+
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1788
|
+
where: {
|
|
1789
|
+
module: "slug",
|
|
1790
|
+
property: ["homepageContentId", "homepageContentModel"]
|
|
1791
|
+
}
|
|
1792
|
+
});
|
|
1793
|
+
const homepageContentId = settings.find((setting) => setting.property === "homepageContentId").value;
|
|
1794
|
+
const homepageContentModel = settings.find((setting) => setting.property === "homepageContentModel").value;
|
|
1795
|
+
const page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
1796
|
+
where: {
|
|
1797
|
+
state: "published",
|
|
1798
|
+
contentId: homepageContentId,
|
|
1799
|
+
contentModel: homepageContentModel
|
|
1800
|
+
}
|
|
1801
|
+
});
|
|
1802
|
+
if (!page) {
|
|
1803
|
+
ctx.status = 404;
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1806
|
+
const properties = ctx.query.properties;
|
|
1807
|
+
if (properties && properties.includes("attributes")) {
|
|
1808
|
+
const attributes2 = await strapi2.db.query(config2.uuid.modules.attribute).findOne({
|
|
1809
|
+
where: {
|
|
1810
|
+
locale: page.locale,
|
|
1811
|
+
contentId: page.contentId,
|
|
1812
|
+
contentModel: page.contentModel,
|
|
1813
|
+
state: "published"
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
const template = attributes2 && attributes2.templateId ? await strapi2.db.query(config2.uuid.modules.template).findOne({
|
|
1817
|
+
where: {
|
|
1818
|
+
documentId: attributes2.templateId
|
|
1819
|
+
}
|
|
1820
|
+
}) : null;
|
|
1821
|
+
page.attributes = {
|
|
1822
|
+
template: template?.uid || "default",
|
|
1823
|
+
priority: attributes2?.priority || "0.5",
|
|
1824
|
+
frequency: attributes2?.frequency || "weekly",
|
|
1825
|
+
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1829
|
+
locale: page.locale,
|
|
1830
|
+
populate: "*",
|
|
1831
|
+
status: "published",
|
|
1832
|
+
documentId: page.contentId
|
|
1833
|
+
});
|
|
1834
|
+
for (const localization of document.localizations) {
|
|
1835
|
+
localization.slug = defaultLocale === localization.locale ? "" : localization.locale;
|
|
1836
|
+
}
|
|
1837
|
+
delete document.createdBy;
|
|
1838
|
+
delete document.updatedBy;
|
|
1839
|
+
document.slug = defaultLocale === page.locale ? "" : page.locale;
|
|
1840
|
+
return {
|
|
1841
|
+
document,
|
|
1842
|
+
...page.attributes ? { attributes: page.attributes } : {}
|
|
1843
|
+
};
|
|
1743
1844
|
}
|
|
1744
1845
|
});
|
|
1745
1846
|
async function fetchAdditionalData(params) {
|
package/dist/server/index.mjs
CHANGED
|
@@ -393,8 +393,8 @@ async function deleteAttributes(event, config2) {
|
|
|
393
393
|
await strapi.db.query(config2.uuid.modules.attribute).updateMany(updateManyWhere);
|
|
394
394
|
}
|
|
395
395
|
const bootstrap = async ({ strapi: strapi2 }) => {
|
|
396
|
+
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
396
397
|
try {
|
|
397
|
-
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
398
398
|
await strapi2.db.query(config2.uuid.app.setting).createMany({
|
|
399
399
|
data: [
|
|
400
400
|
{
|
|
@@ -444,7 +444,25 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
444
444
|
} catch (e) {
|
|
445
445
|
}
|
|
446
446
|
try {
|
|
447
|
-
|
|
447
|
+
await strapi2.db.query(config2.uuid.app.setting).createMany({
|
|
448
|
+
data: [
|
|
449
|
+
{
|
|
450
|
+
module: "slug",
|
|
451
|
+
property: "homepageContentId",
|
|
452
|
+
type: "string",
|
|
453
|
+
value: null
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
module: "slug",
|
|
457
|
+
property: "homepageContentModel",
|
|
458
|
+
type: "string",
|
|
459
|
+
value: null
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
});
|
|
463
|
+
} catch (e) {
|
|
464
|
+
}
|
|
465
|
+
try {
|
|
448
466
|
await strapi2.db.query(config2.uuid.modules.template).createMany({
|
|
449
467
|
data: [
|
|
450
468
|
{
|
|
@@ -1087,6 +1105,9 @@ const SlugModuleController = ({ strapi: strapi2 }) => ({
|
|
|
1087
1105
|
const ctx = strapi2.requestContext.get();
|
|
1088
1106
|
const service = strapi2.plugin(PLUGIN_ID).service("SlugModuleService");
|
|
1089
1107
|
return ctx.query.slug ? await service.getPage() : await service.getPages();
|
|
1108
|
+
},
|
|
1109
|
+
async getHomePage() {
|
|
1110
|
+
return await strapi2.plugin(PLUGIN_ID).service("SlugModuleService").getHomePage();
|
|
1090
1111
|
}
|
|
1091
1112
|
});
|
|
1092
1113
|
const AttributeModuleController = ({ strapi: strapi2 }) => ({
|
|
@@ -1240,6 +1261,16 @@ const contentAPIRoutes = [
|
|
|
1240
1261
|
auth: false
|
|
1241
1262
|
}
|
|
1242
1263
|
},
|
|
1264
|
+
{
|
|
1265
|
+
method: "GET",
|
|
1266
|
+
path: "/modules/pages/home",
|
|
1267
|
+
handler: "SlugModuleController.getHomePage",
|
|
1268
|
+
config: {
|
|
1269
|
+
middlewares: [`plugin::${PLUGIN_ID}.check-module-is-active`],
|
|
1270
|
+
policies: ["check-api-token"],
|
|
1271
|
+
auth: false
|
|
1272
|
+
}
|
|
1273
|
+
},
|
|
1243
1274
|
{
|
|
1244
1275
|
method: "GET",
|
|
1245
1276
|
path: "/modules/menus",
|
|
@@ -1693,20 +1724,28 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1693
1724
|
const properties = ctx.query.properties;
|
|
1694
1725
|
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
1695
1726
|
const defaultLocale = await strapi2.plugin("i18n").service("locales").getDefaultLocale();
|
|
1696
|
-
const
|
|
1727
|
+
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1697
1728
|
where: {
|
|
1698
1729
|
module: "slug",
|
|
1699
|
-
property: "showDefaultLanguage"
|
|
1730
|
+
property: ["showDefaultLanguage", "homepageContentId", "homepageContentModel"]
|
|
1700
1731
|
}
|
|
1701
1732
|
});
|
|
1702
|
-
const showDefaultLanguage = setting.value === "true";
|
|
1733
|
+
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1734
|
+
const homepageContentId = settings.find((setting) => setting.property === "homepageContentId").value;
|
|
1735
|
+
settings.find((setting) => setting.property === "homepageContentModel").value;
|
|
1703
1736
|
const pages = await strapi2.db.query(config2.uuid.modules.slug).findMany({
|
|
1704
1737
|
where: {
|
|
1705
1738
|
state: "published"
|
|
1706
1739
|
}
|
|
1707
1740
|
});
|
|
1708
1741
|
pages.forEach((page) => {
|
|
1709
|
-
|
|
1742
|
+
if (homepageContentId === page.contentId && defaultLocale === page.locale) {
|
|
1743
|
+
page.fullSlug = "";
|
|
1744
|
+
} else if (homepageContentId === page.contentId && defaultLocale !== page.locale) {
|
|
1745
|
+
page.fullSlug = page.locale;
|
|
1746
|
+
} else {
|
|
1747
|
+
page.fullSlug = buildFullSlug({ pages, page, defaultLocale, showDefaultLanguage });
|
|
1748
|
+
}
|
|
1710
1749
|
});
|
|
1711
1750
|
if (properties && properties.includes("attributes")) {
|
|
1712
1751
|
for (const page of pages) {
|
|
@@ -1739,6 +1778,68 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1739
1778
|
...page.attributes ? { attributes: page.attributes } : {}
|
|
1740
1779
|
}));
|
|
1741
1780
|
return mappedPages;
|
|
1781
|
+
},
|
|
1782
|
+
async getHomePage() {
|
|
1783
|
+
const ctx = strapi2.requestContext.get();
|
|
1784
|
+
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
1785
|
+
const defaultLocale = await strapi2.plugin("i18n").service("locales").getDefaultLocale();
|
|
1786
|
+
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1787
|
+
where: {
|
|
1788
|
+
module: "slug",
|
|
1789
|
+
property: ["homepageContentId", "homepageContentModel"]
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
const homepageContentId = settings.find((setting) => setting.property === "homepageContentId").value;
|
|
1793
|
+
const homepageContentModel = settings.find((setting) => setting.property === "homepageContentModel").value;
|
|
1794
|
+
const page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
1795
|
+
where: {
|
|
1796
|
+
state: "published",
|
|
1797
|
+
contentId: homepageContentId,
|
|
1798
|
+
contentModel: homepageContentModel
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
if (!page) {
|
|
1802
|
+
ctx.status = 404;
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
const properties = ctx.query.properties;
|
|
1806
|
+
if (properties && properties.includes("attributes")) {
|
|
1807
|
+
const attributes2 = await strapi2.db.query(config2.uuid.modules.attribute).findOne({
|
|
1808
|
+
where: {
|
|
1809
|
+
locale: page.locale,
|
|
1810
|
+
contentId: page.contentId,
|
|
1811
|
+
contentModel: page.contentModel,
|
|
1812
|
+
state: "published"
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
const template = attributes2 && attributes2.templateId ? await strapi2.db.query(config2.uuid.modules.template).findOne({
|
|
1816
|
+
where: {
|
|
1817
|
+
documentId: attributes2.templateId
|
|
1818
|
+
}
|
|
1819
|
+
}) : null;
|
|
1820
|
+
page.attributes = {
|
|
1821
|
+
template: template?.uid || "default",
|
|
1822
|
+
priority: attributes2?.priority || "0.5",
|
|
1823
|
+
frequency: attributes2?.frequency || "weekly",
|
|
1824
|
+
...attributes2?.parentContentId ? { parent: { id: attributes2.parentContentId, model: attributes2.parentContentModel } } : {}
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
const document = await strapi2.documents(page.contentModel).findOne({
|
|
1828
|
+
locale: page.locale,
|
|
1829
|
+
populate: "*",
|
|
1830
|
+
status: "published",
|
|
1831
|
+
documentId: page.contentId
|
|
1832
|
+
});
|
|
1833
|
+
for (const localization of document.localizations) {
|
|
1834
|
+
localization.slug = defaultLocale === localization.locale ? "" : localization.locale;
|
|
1835
|
+
}
|
|
1836
|
+
delete document.createdBy;
|
|
1837
|
+
delete document.updatedBy;
|
|
1838
|
+
document.slug = defaultLocale === page.locale ? "" : page.locale;
|
|
1839
|
+
return {
|
|
1840
|
+
document,
|
|
1841
|
+
...page.attributes ? { attributes: page.attributes } : {}
|
|
1842
|
+
};
|
|
1742
1843
|
}
|
|
1743
1844
|
});
|
|
1744
1845
|
async function fetchAdditionalData(params) {
|
|
@@ -47,6 +47,7 @@ declare const _default: {
|
|
|
47
47
|
adminGetAll(): Promise<any>;
|
|
48
48
|
adminBulkDelete(): Promise<any>;
|
|
49
49
|
getPages(): Promise<any>;
|
|
50
|
+
getHomePage(): Promise<any>;
|
|
50
51
|
};
|
|
51
52
|
AttributeModuleController: ({ strapi }: {
|
|
52
53
|
/**
|
|
@@ -151,6 +152,10 @@ declare const _default: {
|
|
|
151
152
|
slug: any;
|
|
152
153
|
locale: any;
|
|
153
154
|
}[]>;
|
|
155
|
+
getHomePage(): Promise<{
|
|
156
|
+
attributes?: any;
|
|
157
|
+
document: import("@strapi/types/dist/modules/documents").AnyDocument;
|
|
158
|
+
}>;
|
|
154
159
|
};
|
|
155
160
|
AttributeModuleService: ({ strapi }: {
|
|
156
161
|
strapi: import("@strapi/types/dist/core").Strapi;
|
|
@@ -22,6 +22,10 @@ declare const _default: {
|
|
|
22
22
|
slug: any;
|
|
23
23
|
locale: any;
|
|
24
24
|
}[]>;
|
|
25
|
+
getHomePage(): Promise<{
|
|
26
|
+
attributes?: any;
|
|
27
|
+
document: import("@strapi/types/dist/modules/documents").AnyDocument;
|
|
28
|
+
}>;
|
|
25
29
|
};
|
|
26
30
|
AttributeModuleService: ({ strapi }: {
|
|
27
31
|
strapi: import("@strapi/types/dist/core").Strapi;
|
package/package.json
CHANGED