Skip to content

Commit a3cde41

Browse files
committed
Allow using subpath as a variable in repo
1 parent 682d637 commit a3cde41

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,8 @@ paths:
122122
</tr>
123123
</tbody>
124124
</table>
125+
126+
### Dynamic sub-path
127+
You can use the placeholder `{subpath}` in your `repo` or `display` in
128+
order to create a dynamic subdirectory. I.E map `example.com/group/<any-project-name>` to `github.com/example/group-<any-project-name>`
129+

handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
115115
}{
116116
Import: h.Host(r) + pc.path,
117117
Subpath: subpath,
118-
Repo: pc.repo,
119-
Display: pc.display,
118+
Repo: strings.Replace(pc.repo, "{subpath}", subpath, -1),
119+
Display: strings.Replace(pc.display, "{subpath}", subpath, -1),
120120
VCS: pc.vcs,
121121
}); err != nil {
122122
http.Error(w, "cannot render the page", http.StatusInternalServerError)

vanity.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ paths:
66

77
/launchpad:
88
repo: https://github.com/rakyll/launchpad
9+
10+
/opencensus/:
11+
repo: https://github.com/rakyll/opencensus-{subpath}

0 commit comments

Comments
 (0)