mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-07 22:45:23 +02:00
fix more bugs
This commit is contained in:
parent
8d566c8c78
commit
46539d8833
3 changed files with 7 additions and 4 deletions
|
@ -130,7 +130,9 @@ class PagesOrder {
|
|||
const pageOrder = await PageOrder.get(parentPageId);
|
||||
|
||||
// Create unique array with ordered and unordered pages id
|
||||
pageOrder.order = Array.from(new Set([...pageOrder.order, ...unordered]));
|
||||
pageOrder.order = Array
|
||||
.from(new Set([...pageOrder.order, ...unordered].map(id => id?.toString())))
|
||||
.map(toEntityId);
|
||||
pageOrder.putAbove(currentPageId, putAbovePageId);
|
||||
await pageOrder.save();
|
||||
await PagesFlatArray.regenerate();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import urlify from '../utils/urlify.js';
|
||||
import database from '../database/index.js';
|
||||
import database, {isEqualIds} from '../database/index.js';
|
||||
import { EntityId } from '../database/types.js';
|
||||
|
||||
const pagesDb = database['pages'];
|
||||
|
@ -208,7 +208,7 @@ class Page {
|
|||
if (uri) {
|
||||
let pageWithSameUri = await Page.getByUri(uri);
|
||||
|
||||
while (pageWithSameUri._id && pageWithSameUri._id !== this._id) {
|
||||
while (pageWithSameUri._id && !isEqualIds(pageWithSameUri._id, this._id)) {
|
||||
pageWithSameUriCount++;
|
||||
pageWithSameUri = await Page.getByUri(uri + `-${pageWithSameUriCount}`);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,8 @@ router.post('/page/:id', multer.none(), async (req: Request, res: Response) => {
|
|||
const id = toEntityId(req.params.id);
|
||||
|
||||
try {
|
||||
const { title, body, parent, putAbovePageId, uri } = req.body;
|
||||
const { title, body, putAbovePageId, uri } = req.body;
|
||||
const parent = toEntityId(req.body.parent);
|
||||
const pages = await Pages.getAllPages();
|
||||
let page = await Pages.get(id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue