Commit f278ac18 authored by Daniele Berardo's avatar Daniele Berardo

Merge branch 'add-static-pages-setup' into 'development'

Add static pages setup

See merge request !31
parents a28bcdc8 4843335b
Pipeline #186890158 passed with stages
in 6 minutes and 28 seconds
# This file is a template, and might need editing before it works on your project.
image: node:latest
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- lib/node_modules/
# Default cache directory from https://classic.yarnpkg.com/en/docs/install-ci/#gitlab.
- node_modules/
# Enables git-lab CI caching. Both .cache and public must be cached, otherwise builds will fail.
- .cache/
- public/
before_script:
- cd lib/
......@@ -14,7 +16,7 @@ before_script:
stages:
- build
- test
- deploy
- pages
build:
stage: build
......@@ -31,9 +33,13 @@ test:
- npm install
- npm run test
deploy:
stage: deploy
pages:
stage: pages
script:
- cd ../pages
- npm install
- ./node_modules/.bin/gatsby build --prefix-paths
- cd ../lib
- npm install
- npm run build
- npm run storybook:build
......
......@@ -21,7 +21,7 @@
"start": "webpack-dev-server",
"test-update-snapshots": "jest --updateSnapshot",
"storybook": "start-storybook -p 6006",
"storybook:build": "build-storybook -c .storybook -o ../public",
"storybook:build": "build-storybook -c .storybook -o ../public/storybook",
"storybook:serve": "npx http-server ../public"
},
"devDependencies": {
......
{
"lockfileVersion": 1
}
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"prettier",
"prettier/react"
],
"plugins": ["react", "import", "jsx-a11y"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"react/prop-types": 0,
"react/react-in-jsx-scope": "off",
"lines-between-class-members": ["error", "always"],
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
{
"blankLine": "always",
"prev": ["const", "let", "var"],
"next": ["const", "let", "var"]
},
{ "blankLine": "always", "prev": "directive", "next": "*" },
{ "blankLine": "any", "prev": "directive", "next": "directive" }
]
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 10,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"globals": {
"graphql": false
}
}
public
.cache
node_modules
*DS_Store
*.env
.idea/
const pathPrefix = "/widgets";
const config = {
gatsby: {
pathPrefix,
siteUrl: "https://energenious.eu",
gaTrackingId: null,
trailingSlash: false
},
header: {
logo: "https://energenious.eu/static/energenious.svg",
logoLink: "https://energenious.eu",
title: "",
githubUrl: "https://gitlab.com/energenious/widgets",
helpUrl: "",
tweetText: "",
social: "",
links: [{ text: "", link: "" }],
search: {
enabled: false,
indexName: "",
algoliaAppId: process.env.GATSBY_ALGOLIA_APP_ID,
algoliaSearchKey: process.env.GATSBY_ALGOLIA_SEARCH_KEY,
algoliaAdminKey: process.env.ALGOLIA_ADMIN_KEY
}
},
sidebar: {
forcedNavOrder: [
"/introduction", // add trailing slash if enabled above
"/codeblock"
],
collapsedNav: [
"/codeblock" // add trailing slash if enabled above
],
links: [
{ text: "Energenious", link: "https://energenious.eu" },
{ text: "Live Examples", link: `${pathPrefix}/storybook` }
],
frontline: false,
ignoreIndex: true,
title: "Widgets"
},
siteMetadata: {
title: "Energenious | Widgets",
description: "Widgets project documentation.",
ogImage: null,
docsLocation: "https://gitlab.com/energenious/widgets/pages/content",
favicon: "https://energenious.eu/lay/favicon-32x32.png"
},
pwa: {
enabled: false, // disabling this will also remove the existing service worker.
manifest: {
name: "Gatsby Gitbook Starter",
short_name: "GitbookStarter",
start_url: "/",
background_color: "#6b37bf",
theme_color: "#6b37bf",
display: "standalone",
crossOrigin: "use-credentials",
icons: [
{
src: "src/pwa-512.png",
sizes: `512x512`,
type: `image/png`
}
]
}
}
};
module.exports = config;
---
title: "Syntax Highlighting"
metaTitle: "Syntax Highlighting is the meta title tag for this page"
metaDescription: "This is the meta description for this page"
---
The following is a code block with JavaScript language syntax highlighting.
```javascript
import React from 'react';
```
Supports multiple languages.
The following is a code block with diff. Lines with `+` highlighted in green shade indicating an addition. Lines with `-` highlighted in red shade indicating a deletion.
```javascript
- const data = ['1','2'];
+ const data = [1,2];
```
## Live Editing example
```javascript react-live=true
<button className={'btn btn-default'}>Change my text</button>
```
---
title: "Sub Page"
metaTitle: "Syntax Highlighting is the meta title tag for this page"
metaDescription: "This is the meta description for this page"
---
The following is a code block with JavaScript language syntax highlighting.
```javascript
import React from 'react';
```
Supports multiple languages.
The following is a code block with diff. Lines with `+` highlighted in green shade indicating an addition. Lines with `-` highlighted in red shade indicating a deletion.
```javascript
- const data = ['1','2'];
+ const data = [1,2];
```
## Live Editing example
```javascript react-live=true
<button className={'btn btn-default'}>Change my text</button>
```
---
title: "Landing Page"
---
Some introduction text. Lists out all the headings from h1 to h6. Easy to customise. Some more text. Additional text.
# Heading H1
Heading 1 text
## Heading H2
Heading 2 text
### Heading H3
Heading 3 text
#### Heading H4
Heading 4 text
##### Heading H5
Heading 5 text
###### Heading H6
Heading 6 text
## Lists
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
---
title: "Introduction"
metaTitle: "This is the title tag of this page"
metaDescription: "This is the meta description"
---
Some introduction text. Lists out all the headings from h1 to h6. Easy to customise.
# Heading H1
Heading 1 text
## Heading H2
Heading 2 text
### Heading H3
Heading 3 text
#### Heading H4
Heading 4 text
##### Heading H5
Heading 5 text
###### Heading H6
Heading 6 text
## Lists
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
export const onServiceWorkerUpdateReady = () => {
const answer = window.confirm(
`This tutorial has been updated. ` +
`Reload to display the latest version?`
)
if (answer === true) {
window.location.reload()
}
}
\ No newline at end of file
require("dotenv").config();
const queries = require("./src/utils/algolia");
const config = require("./config");
const plugins = [
'gatsby-plugin-sitemap',
'gatsby-plugin-sharp',
{
resolve: `gatsby-plugin-layout`,
options: {
component: require.resolve(`./src/templates/docs.js`)
}
},
'gatsby-plugin-emotion',
'gatsby-plugin-react-helmet',
{
resolve: "gatsby-source-filesystem",
options: {
name: "docs",
path: `${__dirname}/content/`
}
},
{
resolve: 'gatsby-plugin-mdx',
options: {
gatsbyRemarkPlugins: [
{
resolve: "gatsby-remark-images",
options: {
maxWidth: 1035,
sizeByPixelDensity: true
}
},
{
resolve: 'gatsby-remark-copy-linked-files'
}
],
extensions: [".mdx", ".md"]
}
},
{
resolve: `gatsby-plugin-gtag`,
options: {
// your google analytics tracking id
trackingId: config.gatsby.gaTrackingId,
// Puts tracking script in the head instead of the body
head: true,
// enable ip anonymization
anonymize: false,
},
},
];
// check and add algolia
if (config.header.search && config.header.search.enabled && config.header.search.algoliaAppId && config.header.search.algoliaAdminKey) {
plugins.push({
resolve: `gatsby-plugin-algolia`,
options: {
appId: config.header.search.algoliaAppId, // algolia application id
apiKey: config.header.search.algoliaAdminKey, // algolia admin key to index
queries,
chunkSize: 10000, // default: 1000
}}
)
}
// check and add pwa functionality
if (config.pwa && config.pwa.enabled && config.pwa.manifest) {
plugins.push({
resolve: `gatsby-plugin-manifest`,
options: {...config.pwa.manifest},
});
plugins.push({
resolve: 'gatsby-plugin-offline',
options: {
appendScript: require.resolve(`./src/custom-sw-code.js`),
},
});
} else {
plugins.push('gatsby-plugin-remove-serviceworker');
}
// check and remove trailing slash
if (config.gatsby && !config.gatsby.trailingSlash) {
plugins.push('gatsby-plugin-remove-trailing-slashes');
}
module.exports = {
pathPrefix: config.gatsby.pathPrefix,
siteMetadata: {
title: config.siteMetadata.title,
description: config.siteMetadata.description,
docsLocation: config.siteMetadata.docsLocation,
ogImage: config.siteMetadata.ogImage,
favicon: config.siteMetadata.favicon,
logo: { link: config.header.logoLink ? config.header.logoLink : '/', image: config.header.logo }, // backwards compatible
headerTitle: config.header.title,
githubUrl: config.header.githubUrl,
helpUrl: config.header.helpUrl,
tweetText: config.header.tweetText,
headerLinks: config.header.links,
siteUrl: config.gatsby.siteUrl,
},
plugins: plugins
};
const componentWithMDXScope = require('gatsby-plugin-mdx/component-with-mdx-scope');
const path = require('path');
const startCase = require('lodash.startcase');
const config = require('./config');
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
return new Promise((resolve, reject) => {
resolve(
graphql(
`
{
allMdx {
edges {
node {
fields {
id
}
tableOfContents
fields {
slug
}
}
}
}
}
`
).then(result => {
if (result.errors) {
console.log(result.errors); // eslint-disable-line no-console
reject(result.errors);
}
// Create blog posts pages.
result.data.allMdx.edges.forEach(({ node }) => {
createPage({
path: node.fields.slug ? node.fields.slug : '/',
component: path.resolve('./src/templates/docs.js'),
context: {
id: node.fields.id,
},
});
});
})
);
});
};
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
alias: {
$components: path.resolve(__dirname, 'src/components'),
buble: '@philpl/buble', // to reduce bundle size
},
},
});
};
exports.onCreateBabelConfig = ({ actions }) => {
actions.setBabelPlugin({
name: '@babel/plugin-proposal-export-default-from',
});
};
exports.onCreateNode = ({ node, getNode, actions }) => {
const { createNodeField } = actions;
if (node.internal.type === `Mdx`) {
const parent = getNode(node.parent);
let value = parent.relativePath.replace(parent.ext, '');
if (value === 'index') {
value = '';
}
if (config.gatsby && config.gatsby.trailingSlash) {
createNodeField({
name: `slug`,
node,
value: value === '' ? `/` : `/${value}/`,
});
} else {
createNodeField({
name: `slug`,
node,
value: `/${value}`,
});
}
createNodeField({
name: 'id',
node,
value: node.id,
});
createNodeField({
name: 'title',
node,
value: node.frontmatter.title || startCase(parent.name),
});
}
};
This diff is collapsed.
{
"name": "gatsby-gitbook-boilerplate",
"private": true,
"description": "Documentation, built with mdx",
"author": "Praveen <praveen@hasura.io> (@praveenweb)",
"version": "0.0.1",
"dependencies": {
"@babel/plugin-proposal-export-default-from": "^7.7.4",
"@emotion/core": "^10.0.22",
"@emotion/styled": "^10.0.23",
"@emotion/styled-base": "^10.0.24",
"@mdx-js/loader": "^1.5.1",
"@mdx-js/mdx": "^1.5.1",
"@mdx-js/react": "^1.5.1",
"@philpl/buble": "^0.19.7",
"@playlyfe/gql": "^2.6.2",
"algoliasearch": "^3.35.1",
"dotenv": "^8.2.0",
"emotion": "^10.0.23",
"emotion-server": "^10.0.17",
"emotion-theming": "^10.0.19",
"gatsby": "^2.18.10",
"gatsby-link": "^2.2.27",
"gatsby-plugin-algolia": "^0.5.0",
"gatsby-plugin-emotion": "^4.1.18",
"gatsby-plugin-gtag": "^1.0.12",
"gatsby-plugin-layout": "^1.1.18",
"gatsby-plugin-manifest": "^2.2.33",
"gatsby-plugin-mdx": "^1.0.61",
"gatsby-plugin-offline": "^3.0.29",
"gatsby-plugin-react-helmet": "^3.1.18",
"gatsby-plugin-remove-serviceworker": "^1.0.0",
"gatsby-plugin-sharp": "^2.3.7",
"gatsby-plugin-sitemap": "^2.2.24",
"gatsby-remark-copy-linked-files": "^2.1.33",
"gatsby-remark-images": "^3.1.37",
"gatsby-source-filesystem": "^2.1.42",
"gatsby-transformer-remark": "^2.6.42",
"graphql": "^14.5.8",
"is-absolute-url": "^3.0.3",
"lodash.flatten": "^4.4.0",
"lodash.startcase": "^4.4.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-feather": "^2.0.3",