mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
6da1d8f370
commit
fd0185a84a
2 changed files with 24 additions and 1 deletions
|
@ -56,7 +56,7 @@ func (c *pageFinder) getPageRef(context page.Page, ref string) (page.Page, error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *pageFinder) getPage(context page.Page, ref string) (page.Page, error) {
|
func (c *pageFinder) getPage(context page.Page, ref string) (page.Page, error) {
|
||||||
n, err := c.getContentNode(context, false, paths.ToSlashTrimTrailing(ref))
|
n, err := c.getContentNode(context, false, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,7 @@ func (c *pageFinder) getPageForRefs(ref ...string) (page.Page, error) {
|
||||||
const defaultContentExt = ".md"
|
const defaultContentExt = ".md"
|
||||||
|
|
||||||
func (c *pageFinder) getContentNode(context page.Page, isReflink bool, ref string) (contentNodeI, error) {
|
func (c *pageFinder) getContentNode(context page.Page, isReflink bool, ref string) (contentNodeI, error) {
|
||||||
|
ref = paths.ToSlashTrimTrailing(ref)
|
||||||
inRef := ref
|
inRef := ref
|
||||||
if ref == "" {
|
if ref == "" {
|
||||||
ref = "/"
|
ref = "/"
|
||||||
|
|
|
@ -992,6 +992,28 @@ func TestRefLinking(t *testing.T) {
|
||||||
// TODO: and then the failure cases.
|
// TODO: and then the failure cases.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRelRefWithTrailingSlash(t *testing.T) {
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
-- content/docs/5.3/examples/_index.md --
|
||||||
|
---
|
||||||
|
title: "Examples"
|
||||||
|
---
|
||||||
|
-- content/_index.md --
|
||||||
|
---
|
||||||
|
title: "Home"
|
||||||
|
---
|
||||||
|
|
||||||
|
Examples: {{< relref "/docs/5.3/examples/" >}}
|
||||||
|
-- layouts/home.html --
|
||||||
|
Content: {{ .Content }}|
|
||||||
|
`
|
||||||
|
|
||||||
|
b := Test(t, files)
|
||||||
|
|
||||||
|
b.AssertFileContent("public/index.html", "Examples: /docs/5.3/examples/")
|
||||||
|
}
|
||||||
|
|
||||||
func checkLinkCase(site *Site, link string, currentPage page.Page, relative bool, outputFormat string, expected string, t *testing.T, i int) {
|
func checkLinkCase(site *Site, link string, currentPage page.Page, relative bool, outputFormat string, expected string, t *testing.T, i int) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if out, err := site.refLink(link, currentPage, relative, outputFormat); err != nil || out != expected {
|
if out, err := site.refLink(link, currentPage, relative, outputFormat); err != nil || out != expected {
|
||||||
|
|
Loading…
Reference in a new issue