62
62
</template >
63
63
64
64
<script >
65
- import { resolvePage , normalize , outboundRE , endingSlashRE } from ' ../util'
65
+ import { resolvePage , outboundRE , endingSlashRE } from ' ../util'
66
66
67
67
export default {
68
68
props: [' sidebarItems' ],
@@ -116,14 +116,8 @@ export default {
116
116
docsRepo = repo
117
117
} = this .$site .themeConfig
118
118
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 )
127
121
}
128
122
},
129
123
@@ -146,8 +140,8 @@ export default {
146
140
return (
147
141
base .replace (endingSlashRE, ' ' )
148
142
+ ` /src`
149
- + ` /${ docsBranch} `
150
- + (docsDir ? ' / ' + docsDir .replace (endingSlashRE, ' ' ) : ' ' )
143
+ + ` /${ docsBranch} / `
144
+ + (docsDir ? docsDir .replace (endingSlashRE, ' ' ) + ' / ' : ' ' )
151
145
+ path
152
146
+ ` ?mode=edit&spa=0&at=${ docsBranch} &fileviewer=file-view-default`
153
147
)
@@ -156,11 +150,11 @@ export default {
156
150
const base = outboundRE .test (docsRepo)
157
151
? docsRepo
158
152
: ` https://github.com/${ docsRepo} `
159
-
160
153
return (
161
154
base .replace (endingSlashRE, ' ' )
162
- + ` /edit/${ docsBranch} `
163
- + (docsDir ? ' /' + docsDir .replace (endingSlashRE, ' ' ) : ' ' )
155
+ + ` /edit`
156
+ + ` /${ docsBranch} /`
157
+ + (docsDir ? docsDir .replace (endingSlashRE, ' ' ) + ' /' : ' ' )
164
158
+ path
165
159
)
166
160
}
0 commit comments