Is there any way to check if the current page has been mounted to a different directory?
The reason I’m asking is:
We import a number of Markdown files from other repositories. We also have “edit this page” links which points to the source file on GitHub. We construct the edit URL using the repo URL + .File.Path
This doesn’t work for pages that have been mounted to a different directory with modules. For example, clicking the edit link on this page gives you a 404: Dockerfile reference | Docker Docs
I assume there’s no way for me to construct the actual GitHub URL for the source file. But if there was a way to to a boolean check to see if the current page has been mounted, then I could at least skip rendering the “edit this page” link for these pages.
I’m still interested in the answer to my previous question, but if all dependencies are vendored, they’re all in the _vendor directory, correct?
{{/* Must set enableGitInfo = true in site configuration. */}}
{{ if .File }}
{{ if strings.HasPrefix (strings.TrimPrefix hugo.WorkingDir .File.Filename) "/_vendor/" }}
{{ if .GitInfo }}
I AM FROM A VENDORED MOUNT, AND I HAVE GITINFO
{{ else }}
I AM FROM A VENDORED MOUNT, BUT I DON'T HAVE GITINFO
{{ end }}
{{ else }}
{{ if .GitInfo }}
I AM NOT FROM A MOUNT, AND I HAVE GITINFO
{{ else }}
I AM FROM A NON-VENDORED MOUNT (OR MAYBE YOU HAVEN'T COMMITTED ME YET)
{{ end }}
{{ end }}
{{ else }}
I AM NOT FROM A MOUNT, BUT I DON'T HAVE GITINFO BECAUSE I'M NOT BACKED BY A FILE
{{ end }}
The above should work regardless of whether or not you’ve vendored the dependencies.