@@ -7,7 +7,9 @@ module.exports = (page) => {
77 const repoPage = page . attributes [ 'edit-url-repo-action' ] || 'issues'
88 const repoExtra = repoPage === 'issues' ? 'new' : ''
99 const feedbackTitle = page . attributes [ 'edit-url-title' ] || 'Docs Feedback'
10+ const feedbackBody = page . attributes [ 'edit-url-body' ] || '> Do not include confidential information, personal data, sensitive data, or other regulated data.'
1011 const feedbackLabels = page . attributes [ 'edit-url-labels' ] || ''
12+ let url = page . attributes [ 'edit-url-uri' ] || page . editUrl
1113
1214 // text for the link is based on the edit-url-text attribute, or page theme
1315 const text = ( page . attributes && page . attributes [ 'edit-url-text' ] )
@@ -19,13 +21,30 @@ module.exports = (page) => {
1921 // url for docs can be derived from page.editUrl
2022 // and updated to link to the repo issues page
2123 // for other themes, page.editUrl is used
22- let url = page . editUrl
23- if ( page . attributes && page . attributes . theme === 'docs' ) {
24- const match = url . match ( HOSTED_GIT_REPO_RX )
24+ const match = url . match ( HOSTED_GIT_REPO_RX )
25+ if ( page . attributes && page . attributes . theme === 'docs' && match ) {
2526 const editDetails = match [ 2 ] . split ( '/' )
26- let query = `?title=${ feedbackTitle } : ${ path . join ( ...editDetails . slice ( 4 ) ) } (ref: ${ editDetails [ 3 ] } )`
27- query += feedbackLabels !== '' ? `&labels=${ feedbackLabels } ` : ''
28- url = 'https://' + path . join ( match [ 1 ] , editDetails [ 0 ] , editDetails [ 1 ] , repoPage , repoExtra , query )
27+ const issueParts = {
28+ title : {
29+ text : feedbackTitle ,
30+ path : editDetails . slice ( 4 ) ? path . join ( ...editDetails . slice ( 4 ) ) : '' ,
31+ ref : editDetails [ 3 ] ? `(ref: ${ editDetails [ 3 ] } )` : '' ,
32+ } ,
33+ query : {
34+ body : feedbackBody !== '' ? feedbackBody : '' ,
35+ labels : feedbackLabels !== '' ? feedbackLabels : '' ,
36+ } ,
37+ }
38+
39+ // construct issue content
40+ const issueTitle = '?title=' + Object . values ( issueParts . title ) . join ( ' ' )
41+
42+ // construct query params
43+ const issueQuery = Object . keys ( issueParts . query ) . map ( ( key ) => {
44+ if ( issueParts . query [ key ] !== '' ) return `&${ key } =${ issueParts . query [ key ] } `
45+ } ) . join ( '' )
46+
47+ url = 'https://' + path . join ( match [ 1 ] , editDetails [ 0 ] , editDetails [ 1 ] , repoPage , repoExtra , issueTitle + issueQuery )
2948 }
3049
3150 return {
0 commit comments