diff --git a/src/main/java/run/halo/app/controller/content/ContentContentController.java b/src/main/java/run/halo/app/controller/content/ContentContentController.java index d15ec95877..f33088ed7f 100644 --- a/src/main/java/run/halo/app/controller/content/ContentContentController.java +++ b/src/main/java/run/halo/app/controller/content/ContentContentController.java @@ -93,10 +93,6 @@ public ContentContentController(PostModel postModel, public String content(@PathVariable("prefix") String prefix, @RequestParam(value = "token", required = false) String token, Model model) { - if (optionService.getSheetPermalinkType().equals(SheetPermalinkType.ROOT)) { - Sheet sheet = sheetService.getBySlug(prefix); - return sheetModel.content(sheet, token, model); - } if (optionService.getArchivesPrefix().equals(prefix)) { return postModel.archives(1, model); } @@ -115,7 +111,11 @@ public String content(@PathVariable("prefix") String prefix, if (optionService.getLinksPrefix().equals(prefix)) { return linkModel.list(model); } - return null; + if (optionService.getSheetPermalinkType().equals(SheetPermalinkType.ROOT)) { + Sheet sheet = sheetService.getBySlug(prefix); + return sheetModel.content(sheet, token, model); + } + throw new NotFoundException("Not Found"); } @GetMapping("{prefix}/page/{page:\\d+}") @@ -155,12 +155,6 @@ public String content(@PathVariable("prefix") String prefix, } } - if (optionService.getSheetPermalinkType().equals(SheetPermalinkType.SECONDARY) - && optionService.getSheetPrefix().equals(prefix)) { - Sheet sheet = sheetService.getBySlug(slug); - return sheetModel.content(sheet, token, model); - } - if (optionService.getCategoriesPrefix().equals(prefix)) { return categoryModel.listPost(model, slug, 1); } @@ -175,6 +169,12 @@ public String content(@PathVariable("prefix") String prefix, return postModel.content(post, token, model); } + if (optionService.getSheetPermalinkType().equals(SheetPermalinkType.SECONDARY) + && optionService.getSheetPrefix().equals(prefix)) { + Sheet sheet = sheetService.getBySlug(slug); + return sheetModel.content(sheet, token, model); + } + throw new NotFoundException("Not Found"); }