mirror of https://github.com/halo-dev/halo
Update robots router.
parent
eb7ff715c2
commit
463b786671
|
@ -16,6 +16,7 @@ import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
|||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||
import run.halo.app.config.properties.HaloProperties;
|
||||
import run.halo.app.model.entity.Post;
|
||||
import run.halo.app.model.enums.PostStatus;
|
||||
import run.halo.app.model.vo.PostListVO;
|
||||
|
@ -43,13 +44,16 @@ public class ContentFeedController {
|
|||
private final PostService postService;
|
||||
private final OptionService optionService;
|
||||
private final FreeMarkerConfigurer freeMarker;
|
||||
private final HaloProperties haloProperties;
|
||||
|
||||
public ContentFeedController(PostService postService,
|
||||
OptionService optionService,
|
||||
FreeMarkerConfigurer freeMarker) {
|
||||
FreeMarkerConfigurer freeMarker,
|
||||
HaloProperties haloProperties) {
|
||||
this.postService = postService;
|
||||
this.optionService = optionService;
|
||||
this.freeMarker = freeMarker;
|
||||
this.haloProperties = haloProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,6 +129,8 @@ public class ContentFeedController {
|
|||
@GetMapping(value = "robots.txt", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
@ResponseBody
|
||||
public String robots(Model model) throws IOException, TemplateException {
|
||||
String adminPath = haloProperties.getAdminPath();
|
||||
model.addAttribute("adminPath", adminPath);
|
||||
Template template = freeMarker.getConfiguration().getTemplate("common/web/robots.ftl");
|
||||
return FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ User-agent: /
|
|||
Disallow: /
|
||||
<#else>
|
||||
User-agent: *
|
||||
Disallow: /admin/
|
||||
Disallow: ${adminPath!}/
|
||||
Sitemap: ${context!}/sitemap.xml
|
||||
Sitemap: ${context!}/sitemap.html
|
||||
</#if>
|
Loading…
Reference in New Issue