aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-docs/src
diff options
context:
space:
mode:
authorPascal Mugnier <pascal.mugnier@sonarsource.com>2018-10-25 14:27:13 +0200
committersonartech <sonartech@sonarsource.com>2018-10-30 12:42:04 +0100
commitd55090a928fdedad0f88d46fcf6976f8db796bf7 (patch)
treef3a7f058014a850805c6deca5952f0023d35a184 /server/sonar-docs/src
parentcc4a4150cd74ceb38f2bb08e421b126a59a0f932 (diff)
downloadsonarqube-d55090a928fdedad0f88d46fcf6976f8db796bf7.tar.gz
sonarqube-d55090a928fdedad0f88d46fcf6976f8db796bf7.zip
SONAR-11307 Enhance embedded documentation with nav metadata
Diffstat (limited to 'server/sonar-docs/src')
-rw-r--r--server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js9
-rw-r--r--server/sonar-docs/src/layouts/components/CategoryLink.js5
-rw-r--r--server/sonar-docs/src/layouts/components/SubpageLink.js3
-rw-r--r--server/sonar-docs/src/layouts/index.js1
-rw-r--r--server/sonar-docs/src/pages/404.md1
5 files changed, 16 insertions, 3 deletions
diff --git a/server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js b/server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js
index 91a47bc91a4..fdf2a42ad37 100644
--- a/server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js
+++ b/server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js
@@ -33,6 +33,15 @@ beforeAll(async () => {
});
});
+it('should have at least one instance of all possible frontmatter fields', () => {
+ let pageWithTitle = parsedFiles.find(file => file.frontmatter.title !== undefined);
+ let pageWithNav = parsedFiles.find(file => file.frontmatter.nav !== undefined);
+ let pageWithUrl = parsedFiles.find(file => file.frontmatter.url !== undefined);
+ expect(pageWithTitle).toBeDefined();
+ expect(pageWithNav).toBeDefined();
+ expect(pageWithUrl).toBeDefined();
+});
+
it('should have valid links in trees files', () => {
const trees = [
'SonarCloudNavigationTree.json',
diff --git a/server/sonar-docs/src/layouts/components/CategoryLink.js b/server/sonar-docs/src/layouts/components/CategoryLink.js
index aa3ef073347..de708652ad0 100644
--- a/server/sonar-docs/src/layouts/components/CategoryLink.js
+++ b/server/sonar-docs/src/layouts/components/CategoryLink.js
@@ -41,14 +41,15 @@ export default class CategoryLink extends React.PureComponent {
const prefix = process.env.GATSBY_DOCS_VERSION ? '/' + process.env.GATSBY_DOCS_VERSION : '';
const url = node ? node.frontmatter.url || node.fields.slug : '';
const isCurrentPage = location.pathname === prefix + url;
+ const linkTitle = node ? node.frontmatter.nav || node.frontmatter.title : '';
return (
<div>
{node ? (
<Link
className={isCurrentPage || open ? 'page-indexes-link active' : 'page-indexes-link'}
to={url}
- title={node.frontmatter.title}>
- {node.frontmatter.title}
+ title={linkTitle}>
+ {linkTitle}
</Link>
) : (
<a
diff --git a/server/sonar-docs/src/layouts/components/SubpageLink.js b/server/sonar-docs/src/layouts/components/SubpageLink.js
index c0027e3ed76..f3977b21be3 100644
--- a/server/sonar-docs/src/layouts/components/SubpageLink.js
+++ b/server/sonar-docs/src/layouts/components/SubpageLink.js
@@ -22,10 +22,11 @@ import Link from 'gatsby-link';
import HeadingsLink from './HeadingsLink';
export default function SubpageLink({ node, active }) {
+ const linkTitle = node.frontmatter.nav || node.frontmatter.title;
return (
<div>
<Link className={active ? 'sub-menu-link active' : 'sub-menu-link'} to={node.fields.slug}>
- {node.frontmatter.title}
+ {linkTitle}
</Link>
</div>
);
diff --git a/server/sonar-docs/src/layouts/index.js b/server/sonar-docs/src/layouts/index.js
index a65714c59c2..fe7a97cf4c5 100644
--- a/server/sonar-docs/src/layouts/index.js
+++ b/server/sonar-docs/src/layouts/index.js
@@ -69,6 +69,7 @@ export const query = graphql`
}
frontmatter {
title
+ nav
url
}
fields {
diff --git a/server/sonar-docs/src/pages/404.md b/server/sonar-docs/src/pages/404.md
index d6a0f85fd7e..ef227477acb 100644
--- a/server/sonar-docs/src/pages/404.md
+++ b/server/sonar-docs/src/pages/404.md
@@ -1,5 +1,6 @@
---
title: Page not found
+nav: Not found
url: /404/
---