Skip to content

Commit 822dae3

Browse files
committed
Add body, fix query params
1 parent 19a677f commit 822dae3

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

preview-src/tables.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
= Tables
22
:nofooter:
3+
:page-theme: docs
34
:page-ogtitle: This page uses the page-ogtitle attribute to generate a custom title for SEO meta
5+
// :page-edit-url-body: Custom raise an issue body text
6+
// :page-edit-url-title: Custom raise an issue title text
7+
:page-edit-url-uri: https://github.com/neo4j/docs-cypher/blob/dev/modules/ROOT/pages/queries/index.adoc
48

59
.No striping
610
// Alternative to stripes attributes is

src/helpers/edit-url-text.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)