115 lines
5.7 KiB
JavaScript
115 lines
5.7 KiB
JavaScript
|
"use strict";
|
||
|
exports.id = 6000;
|
||
|
exports.ids = [6000];
|
||
|
exports.modules = {
|
||
|
|
||
|
/***/ 6000:
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
|
/* harmony export */ "Z": () => (/* binding */ DocsAside)
|
||
|
/* harmony export */ });
|
||
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997);
|
||
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
||
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
|
||
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
||
|
// @ts-check
|
||
|
/**
|
||
|
* ==============================================================================
|
||
|
* Imports
|
||
|
* ==============================================================================
|
||
|
*/
|
||
|
|
||
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||
|
* ==============================================================================
|
||
|
* Main Component { Functional }
|
||
|
* ==============================================================================
|
||
|
* @param {Object} props - Server props
|
||
|
* @param {import("@/package-shared/types").DocsAsidePageObject[]} props.pages
|
||
|
*/ function DocsAside({ pages }) {
|
||
|
/**
|
||
|
* Get Contexts
|
||
|
*
|
||
|
* @abstract { React.useContext }
|
||
|
*/ if (!pages || !pages[0]) return null;
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* Javascript Variables
|
||
|
*
|
||
|
* @abstract Non hook variables and functions
|
||
|
*/ const topLevelPages = pages?.filter((page)=>page.level == 1);
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* React Hooks
|
||
|
*
|
||
|
* @abstract { useState, useEffect, useRef, etc ... }
|
||
|
*/ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
|
||
|
////////////////////////////////////////
|
||
|
/** @type {NodeListOf<HTMLAnchorElement>} */ let asideLinks = document.querySelectorAll("aside a");
|
||
|
if (asideLinks && asideLinks[0]) {
|
||
|
asideLinks.forEach((link)=>{
|
||
|
if (link.pathname === window.location.pathname) {
|
||
|
link.classList.add("active");
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}, []);
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* ## Generate List Function
|
||
|
* @param {import("@/package-shared/types").DocsAsidePageObject[]} cPages
|
||
|
* @param {string} baseUrl
|
||
|
* @returns
|
||
|
*/ function generateList(cPages, baseUrl) {
|
||
|
return cPages.map((page, index)=>{
|
||
|
const url = `${baseUrl}/${page.slug}`;
|
||
|
const childrenPages = pages.filter((pg)=>pg.level == 2 && pg.parent_id == page.id);
|
||
|
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("li", {
|
||
|
children: [
|
||
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("a", {
|
||
|
href: url,
|
||
|
className: page?.level == 1 ? "font-semibold" : "text-slate-600",
|
||
|
children: page.title
|
||
|
}),
|
||
|
childrenPages && childrenPages[0] && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("ul", {
|
||
|
className: "pl-4 gap-2 flex flex-col items-start text-sm mt-2",
|
||
|
children: generateList(childrenPages, url)
|
||
|
})
|
||
|
]
|
||
|
}, index);
|
||
|
});
|
||
|
}
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* Function Return
|
||
|
*
|
||
|
* @abstract Main Function Return
|
||
|
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("aside", {
|
||
|
className: "w-full lg:w-80 p-10 bg-slate-100 dark:bg-slate-800 sticky top-0 overflow-y-auto max-h-max lg:max-h-screen transition-all",
|
||
|
children: [
|
||
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
|
||
|
className: "text-2xl m-0 mb-4 text-left font-semibold",
|
||
|
children: "Docs"
|
||
|
}),
|
||
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("ul", {
|
||
|
className: "pl-4 gap-4 flex flex-col items-start",
|
||
|
children: generateList(topLevelPages, "/docs")
|
||
|
})
|
||
|
]
|
||
|
});
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
||
|
|
||
|
|
||
|
/***/ })
|
||
|
|
||
|
};
|
||
|
;
|