add #shareRoot label to define an "index" note, closes #2567

This commit is contained in:
zadam
2022-01-17 23:13:56 +01:00
parent 1aff3db81f
commit 52b118df7f
12 changed files with 115 additions and 84 deletions

View File

@@ -21,13 +21,7 @@ function getSharedSubTreeRoot(note) {
}
function register(router) {
router.get('/share/:shareId', (req, res, next) => {
const {shareId} = req.params;
shacaLoader.ensureLoad();
const note = shaca.aliasToNote[shareId] || shaca.notes[shareId];
function renderNote(note, res) {
if (note) {
const {header, content, isEmpty} = contentRenderer.getContent(note);
@@ -40,10 +34,25 @@ function register(router) {
isEmpty,
subRoot
});
}
else {
} else {
res.status(404).render("share/404");
}
}
router.get(['/share', '/share/'], (req, res, next) => {
shacaLoader.ensureLoad();
renderNote(shaca.shareRootNote, res);
});
router.get('/share/:shareId', (req, res, next) => {
const {shareId} = req.params;
shacaLoader.ensureLoad();
const note = shaca.aliasToNote[shareId] || shaca.notes[shareId];
renderNote(note, res);
});
router.get('/share/api/notes/:noteId', (req, res, next) => {