apostrophe 3.49.0 → 3.50.0
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/CHANGELOG.md +12 -0
- package/modules/@apostrophecms/page/index.js +61 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.50.0 (2023-06-09)
|
|
4
|
+
|
|
5
|
+
### Adds
|
|
6
|
+
|
|
7
|
+
* As a further fix for issues that could ensue before the improvements
|
|
8
|
+
to locale renaming support that were released in 3.49.0, an
|
|
9
|
+
`@apostrophecms/page:reattach` task has been added. This command line task
|
|
10
|
+
takes the `_id` or `slug` of a page and reattaches it to the page tree as
|
|
11
|
+
the last child of the home page, even if page tree data for that page
|
|
12
|
+
is corrupted. You may wish to use the `--new-slug` and `--locale` options. This task should not
|
|
13
|
+
be needed in normal circumstances.
|
|
14
|
+
|
|
3
15
|
## 3.49.0 (2023-06-08)
|
|
4
16
|
|
|
5
17
|
### Changes
|
|
@@ -2007,6 +2007,63 @@ database.`);
|
|
|
2007
2007
|
throw 'No page with that slug was found.';
|
|
2008
2008
|
}
|
|
2009
2009
|
},
|
|
2010
|
+
// Reattach a page as the last child of the home page even if
|
|
2011
|
+
// the page tree properties are corrupted
|
|
2012
|
+
async reattachTask(argv) {
|
|
2013
|
+
if (argv._.length !== 2) {
|
|
2014
|
+
throw new Error('Wrong number of arguments');
|
|
2015
|
+
}
|
|
2016
|
+
const modes = [ 'draft', 'published' ];
|
|
2017
|
+
const slugOrId = argv._[1];
|
|
2018
|
+
for (const mode of modes) {
|
|
2019
|
+
// Note that page moves are autopublished
|
|
2020
|
+
const req = self.apos.task.getReq({
|
|
2021
|
+
mode
|
|
2022
|
+
});
|
|
2023
|
+
const home = await self.findOneForEditing(req, {
|
|
2024
|
+
slug: '/'
|
|
2025
|
+
});
|
|
2026
|
+
if (!home) {
|
|
2027
|
+
throw `No home page was found in ${req.locale}. Exiting.`;
|
|
2028
|
+
}
|
|
2029
|
+
const page = await self.findOneForEditing(req, {
|
|
2030
|
+
$or: [
|
|
2031
|
+
{
|
|
2032
|
+
slug: slugOrId
|
|
2033
|
+
},
|
|
2034
|
+
{
|
|
2035
|
+
_id: slugOrId
|
|
2036
|
+
}
|
|
2037
|
+
]
|
|
2038
|
+
});
|
|
2039
|
+
if (!page) {
|
|
2040
|
+
console.log(`No page with that slug or _id was found in ${req.locale}:${req.mode}.`);
|
|
2041
|
+
} else {
|
|
2042
|
+
const rank = (await self.apos.doc.db.find({
|
|
2043
|
+
path: self.matchDescendants(home),
|
|
2044
|
+
aposLocale: req.locale,
|
|
2045
|
+
level: home.level + 1
|
|
2046
|
+
}).project({ rank: 1 }).sort({ rank: 1 }).toArray()).reduce((memo, page) => Math.max(memo, page.rank), 0) + 1;
|
|
2047
|
+
page.path = `${home.path}/${page.aposDocId}`;
|
|
2048
|
+
page.rank = rank;
|
|
2049
|
+
const $set = {
|
|
2050
|
+
path: page.path,
|
|
2051
|
+
rank: page.rank,
|
|
2052
|
+
aposLastTargetId: home.aposDocId,
|
|
2053
|
+
aposLastPosition: 'lastChild'
|
|
2054
|
+
};
|
|
2055
|
+
if (argv['new-slug']) {
|
|
2056
|
+
$set.slug = argv['new-slug'];
|
|
2057
|
+
}
|
|
2058
|
+
await self.apos.doc.db.updateOne({
|
|
2059
|
+
_id: page._id
|
|
2060
|
+
}, {
|
|
2061
|
+
$set
|
|
2062
|
+
});
|
|
2063
|
+
console.log(`Reattached as the last child of the home page in ${req.locale}:${req.mode}.`);
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
},
|
|
2010
2067
|
// Invoked by the @apostrophecms/version module.
|
|
2011
2068
|
//
|
|
2012
2069
|
// Your module can add additional doc properties that should never be rolled back by pushing
|
|
@@ -2442,6 +2499,10 @@ database.`);
|
|
|
2442
2499
|
unpark: {
|
|
2443
2500
|
usage: 'Usage: node app @apostrophecms/page:unpark /page/slug\n\nThis unparks a page that was formerly locked in a specific\nposition in the page tree.',
|
|
2444
2501
|
task: self.unparkTask
|
|
2502
|
+
},
|
|
2503
|
+
reattach: {
|
|
2504
|
+
usage: 'Usage: node app @apostrophecms/page:reattach _id-or-slug',
|
|
2505
|
+
task: self.reattachTask
|
|
2445
2506
|
}
|
|
2446
2507
|
};
|
|
2447
2508
|
}
|