mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	Merge pull request #43 from hugoduncan/feature/allow-xhtml-aliases
Enable aliases from .xhtml paths
This commit is contained in:
		@@ -184,9 +184,13 @@ func (s *Site) generateTemplateNameFrom(path string) (name string) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (s *Site) primeTemplates() {
 | 
					func (s *Site) primeTemplates() {
 | 
				
			||||||
	alias := "<!DOCTYPE html>\n <html>\n <head>\n <link rel=\"canonical\" href=\"{{ .Permalink }}\"/>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"refresh\" content=\"0;url={{ .Permalink }}\" />\n </head>\n </html>"
 | 
						alias := "<!DOCTYPE html>\n <html>\n <head>\n <link rel=\"canonical\" href=\"{{ .Permalink }}\"/>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"refresh\" content=\"0;url={{ .Permalink }}\" />\n </head>\n </html>"
 | 
				
			||||||
 | 
						alias_xhtml := "<!DOCTYPE html>\n <html xmlns=\"http://www.w3.org/1999/xhtml\">\n <head>\n <link rel=\"canonical\" href=\"{{ .Permalink }}\"/>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"refresh\" content=\"0;url={{ .Permalink }}\" />\n </head>\n </html>"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t := s.Tmpl.New("alias")
 | 
						t := s.Tmpl.New("alias")
 | 
				
			||||||
	template.Must(t.Parse(alias))
 | 
						template.Must(t.Parse(alias))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t = s.Tmpl.New("alias-xhtml")
 | 
				
			||||||
 | 
						template.Must(t.Parse(alias_xhtml))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *Site) initialize() {
 | 
					func (s *Site) initialize() {
 | 
				
			||||||
@@ -415,7 +419,11 @@ func inStringArray(arr []string, el string) bool {
 | 
				
			|||||||
func (s *Site) RenderAliases() error {
 | 
					func (s *Site) RenderAliases() error {
 | 
				
			||||||
	for i, p := range s.Pages {
 | 
						for i, p := range s.Pages {
 | 
				
			||||||
		for _, a := range p.Aliases {
 | 
							for _, a := range p.Aliases {
 | 
				
			||||||
			content, err := s.RenderThing(s.Pages[i], "alias")
 | 
								t := "alias";
 | 
				
			||||||
 | 
								if strings.HasSuffix(a, ".xhtml") {
 | 
				
			||||||
 | 
									t = "alias-xhtml"
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								content, err := s.RenderThing(s.Pages[i], t)
 | 
				
			||||||
			if strings.HasSuffix(a, "/") {
 | 
								if strings.HasSuffix(a, "/") {
 | 
				
			||||||
				a = a + "index.html"
 | 
									a = a + "index.html"
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user