diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-04-30 15:41:18 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-05-03 20:20:51 +0200 |
commit | 95c2ca3b5880aaf1050fbfc0c009df587e172039 (patch) | |
tree | c668d2c9bb747e5590ca915196ef7792c52d23c8 /server/sonar-docs/src/templates | |
parent | b083d4376580b8dd252933025ca86ce5b98ce7af (diff) | |
download | sonarqube-95c2ca3b5880aaf1050fbfc0c009df587e172039.tar.gz sonarqube-95c2ca3b5880aaf1050fbfc0c009df587e172039.zip |
SONAR-10613 Generate a documentation static website (#196)
Diffstat (limited to 'server/sonar-docs/src/templates')
-rw-r--r-- | server/sonar-docs/src/templates/page.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/server/sonar-docs/src/templates/page.js b/server/sonar-docs/src/templates/page.js new file mode 100644 index 00000000000..0a4347fdabb --- /dev/null +++ b/server/sonar-docs/src/templates/page.js @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; +import Helmet from 'react-helmet'; + +export default ({ data }) => { + const page = data.markdownRemark; + const htmlWithInclusions = page.html.replace(/\<p\>@include (.*)\<\/p\>/, (_, path) => { + const chunk = data.allMarkdownRemark.edges.find(edge => edge.node.fields.slug === path); + return chunk ? chunk.node.html : ''; + }); + + return ( + <div css={{ paddingTop: 24, paddingBottom: 24 }}> + <Helmet title={page.frontmatter.title} /> + <h1>{page.frontmatter.title}</h1> + <div dangerouslySetInnerHTML={{ __html: htmlWithInclusions }} /> + </div> + ); +}; + +export const query = graphql` + query PageQuery($slug: String!) { + allMarkdownRemark { + edges { + node { + html + fields { + slug + } + } + } + } + markdownRemark(fields: { slug: { eq: $slug } }) { + html + frontmatter { + title + } + } + } +`; |