6262</template >
6363
6464<script >
65- import { resolvePage , normalize , outboundRE , endingSlashRE } from ' ../util'
65+ import { resolvePage , outboundRE , endingSlashRE } from ' ../util'
6666
6767export default {
6868 props: [' sidebarItems' ],
@@ -116,14 +116,8 @@ export default {
116116 docsRepo = repo
117117 } = this .$site .themeConfig
118118
119- let path = normalize (this .$page .path )
120- if (endingSlashRE .test (path)) {
121- path += ' README.md'
122- } else {
123- path += ' .md'
124- }
125- if (docsRepo && editLinks) {
126- return this .createEditLink (repo, docsRepo, docsDir, docsBranch, path)
119+ if (docsRepo && editLinks && this .$page .relativePath ) {
120+ return this .createEditLink (repo, docsRepo, docsDir, docsBranch, this .$page .relativePath )
127121 }
128122 },
129123
@@ -146,8 +140,8 @@ export default {
146140 return (
147141 base .replace (endingSlashRE, ' ' )
148142 + ` /src`
149- + ` /${ docsBranch} `
150- + (docsDir ? ' / ' + docsDir .replace (endingSlashRE, ' ' ) : ' ' )
143+ + ` /${ docsBranch} / `
144+ + (docsDir ? docsDir .replace (endingSlashRE, ' ' ) + ' / ' : ' ' )
151145 + path
152146 + ` ?mode=edit&spa=0&at=${ docsBranch} &fileviewer=file-view-default`
153147 )
@@ -156,11 +150,11 @@ export default {
156150 const base = outboundRE .test (docsRepo)
157151 ? docsRepo
158152 : ` https://github.com/${ docsRepo} `
159-
160153 return (
161154 base .replace (endingSlashRE, ' ' )
162- + ` /edit/${ docsBranch} `
163- + (docsDir ? ' /' + docsDir .replace (endingSlashRE, ' ' ) : ' ' )
155+ + ` /edit`
156+ + ` /${ docsBranch} /`
157+ + (docsDir ? docsDir .replace (endingSlashRE, ' ' ) + ' /' : ' ' )
164158 + path
165159 )
166160 }
0 commit comments