});
});
+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',
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
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>
);
}
frontmatter {
title
+ nav
url
}
fields {
---
title: Page not found
+nav: Not found
url: /404/
---
key={node.url}
style={{ paddingLeft: indent ? 31 : 10 }}
to={'/documentation' + node.url}>
- <h3 className="list-group-item-heading">{node.title}</h3>
+ <h3 className="list-group-item-heading">{node.navTitle || node.title}</h3>
</Link>
);
}
import Menu from '../Menu';
function createPage(title: string, relativeName: string, text = '') {
- return { relativeName, url: '/' + relativeName, title, text, content: text };
+ return { relativeName, url: '/' + relativeName, title, navTitle: undefined, text, content: text };
}
const pages = [
relativeName: '/bar/',
text: 'bar',
title: 'Bar',
+ navTitle: undefined,
url: '/bar/'
},
{
relativeName: '/baz/',
text: 'baz',
title: 'baz',
+ navTitle: 'baznav',
url: '/baz/'
}
];
relativeName: 'foo/bar',
url: '/foo/bar',
text: 'Foobar is a universal variable understood to represent whatever is being discussed.',
- title: 'Foobar'
+ title: 'Foobar',
+ navTitle: undefined
};
describe('SearchResultEntry', () => {
}));
function createPage(title: string, relativeName: string, text = '') {
- return { relativeName, url: '/' + relativeName, title, text, content: text };
+ return { relativeName, url: '/' + relativeName, title, navTitle: undefined, text, content: text };
}
const pages = [
import Sidebar from '../Sidebar';
function createPage(title: string, relativeName: string, text = '') {
- return { relativeName, url: '/' + relativeName, title, text, content: text };
+ return { relativeName, url: '/' + relativeName, title, navTitle: undefined, text, content: text };
}
const pages = [
Array [
Object {
"content": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
+ "navTitle": undefined,
"relativeName": "lorem/index",
"text": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"title": "Lorem Ipsum",
},
Object {
"content": "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words.",
+ "navTitle": undefined,
"relativeName": "lorem/origin",
"text": "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words.",
"title": "Where does it come from?",
},
Object {
"content": "Foobar is a universal variable understood to represent whatever is being discussed.",
+ "navTitle": undefined,
"relativeName": "foobar",
"text": "Foobar is a universal variable understood to represent whatever is being discussed.",
"title": "Where does Foobar come from?",
node={
Object {
"content": "bar",
+ "navTitle": undefined,
"relativeName": "/bar/",
"text": "bar",
"title": "Bar",
node={
Object {
"content": "baz",
+ "navTitle": "baznav",
"relativeName": "/baz/",
"text": "baz",
"title": "baz",
"longestTerm": "",
"page": Object {
"content": "",
+ "navTitle": undefined,
"relativeName": "foo/bar",
"text": "Foobar is a universal variable understood to represent whatever is being discussed.",
"title": "Foobar",
"longestTerm": "",
"page": Object {
"content": "",
+ "navTitle": undefined,
"relativeName": "foo/bar",
"text": "Foobar is a universal variable understood to represent whatever is being discussed.",
"title": "Foobar",
"longestTerm": "from",
"page": Object {
"content": "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words.",
+ "navTitle": undefined,
"relativeName": "lorem/origin",
"text": "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words.",
"title": "Where does it come from?",
"longestTerm": "from",
"page": Object {
"content": "Foobar is a universal variable understood to represent whatever is being discussed.",
+ "navTitle": undefined,
"relativeName": "foobar",
"text": "Foobar is a universal variable understood to represent whatever is being discussed.",
"title": "Where does Foobar come from?",
Array [
Object {
"content": "",
+ "navTitle": undefined,
"relativeName": "lorem/index",
"text": "",
"title": "Lorem Ipsum",
},
Object {
"content": "",
+ "navTitle": undefined,
"relativeName": "foobar",
"text": "",
"title": "Where does Foobar come from?",
Array [
Object {
"content": "",
+ "navTitle": undefined,
"relativeName": "lorem/index",
"text": "",
"title": "Lorem Ipsum",
},
Object {
"content": "",
+ "navTitle": undefined,
"relativeName": "foobar",
"text": "",
"title": "Where does Foobar come from?",
relativeName: file.path,
url: parsed.frontmatter.url || `/${file.path}`,
title: parsed.frontmatter.title,
+ navTitle: parsed.frontmatter.nav || undefined,
order: Number(parsed.frontmatter.order || -1),
scope: parsed.frontmatter.scope
? (parsed.frontmatter.scope.toLowerCase() as DocumentationEntryScope)
export interface DocumentationEntry {
content: string;
relativeName: string;
+ navTitle: string | undefined;
text: string;
title: string;
url: string;