-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement base constants and Gatsby configuration with basic plugins
All metadata and constants, like defined in GH-26, are placed in the corresponding folders for configurations (`src/config`) and data (`src/data`). Initially this includes information stored in the `package.json` file of the project and the `nord` package which has also been installed. This commit also adds base and important constants that will be used later on: - `src/config/internal/constants.js` - Provides internally used constants - `src/config/internal/nodes.js` - Provides internally used data about custom Gatsby GraphQL API nodes. - `src/config/routes/constants.js` - Provides routing constants. - `src/config/routes/mappings.js` - Provides route mapping constants. GH-27
- Loading branch information
1 parent
acf5aee
commit b8e9ff2
Showing
8 changed files
with
460 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
/** | ||
* @file The Gatsby configuration. | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @see https://gatsbyjs.org/docs/gatsby-config | ||
* @since 0.1.0 | ||
*/ | ||
|
||
const { metadataNord, metadataNordDocs } = require("./src/data/project"); | ||
const { sourceInstanceTypes } = require("./src/config/internal/nodes"); | ||
const { | ||
BASE_DIR_CONTENT, | ||
BASE_DIR_ASSETS_IMAGES, | ||
BASE_DIR_CONFIG, | ||
BASE_DIR_PAGES | ||
} = require("./src/config/internal/constants"); | ||
const { BASE_PUBLIC_URL } = require("./src/config/routes/constants"); | ||
|
||
module.exports = { | ||
siteMetadata: { | ||
nord: { ...metadataNord }, | ||
...metadataNordDocs | ||
}, | ||
plugins: [ | ||
"gatsby-plugin-react-helmet", | ||
"gatsby-plugin-catch-links", | ||
"gatsby-plugin-remove-trailing-slashes", | ||
"gatsby-plugin-no-sourcemaps", | ||
"gatsby-transformer-yaml", | ||
{ | ||
resolve: "gatsby-plugin-canonical-urls", | ||
options: { | ||
siteUrl: `${BASE_PUBLIC_URL}` | ||
} | ||
}, | ||
{ | ||
resolve: "gatsby-source-filesystem", | ||
options: { | ||
name: "images", | ||
path: `${__dirname}/${BASE_DIR_ASSETS_IMAGES}` | ||
} | ||
}, | ||
{ | ||
resolve: "gatsby-source-filesystem", | ||
options: { | ||
name: `${sourceInstanceTypes.blog.id}`, | ||
path: `${__dirname}/${BASE_DIR_CONTENT}/${sourceInstanceTypes.blog.path}/` | ||
} | ||
}, | ||
{ | ||
resolve: "gatsby-source-filesystem", | ||
options: { | ||
name: "config", | ||
path: `${__dirname}/${BASE_DIR_CONFIG}/` | ||
} | ||
}, | ||
{ | ||
resolve: "gatsby-source-filesystem", | ||
options: { | ||
name: `${sourceInstanceTypes.docs.id}`, | ||
path: `${__dirname}/${BASE_DIR_CONTENT}/${sourceInstanceTypes.docs.path}/` | ||
} | ||
}, | ||
{ | ||
resolve: "gatsby-source-filesystem", | ||
options: { | ||
name: "pages", | ||
path: `${__dirname}/${BASE_DIR_PAGES}/` | ||
} | ||
} | ||
] | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
/** | ||
* @file Provides internally used constants. | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.1.0 | ||
*/ | ||
|
||
/** | ||
* The absolute path of the content base directory starting from the project root. | ||
* | ||
* @constant {String} | ||
* @since 0.1.0 | ||
*/ | ||
const BASE_DIR_CONTENT = "content"; | ||
|
||
/** | ||
* The absolute path of the sources base directory starting from the project root. | ||
* | ||
* @constant {string} | ||
* @since 0.1.0 | ||
*/ | ||
const BASE_DIR_SRC = "src"; | ||
|
||
/** | ||
* The absolute path of the assets base directory starting from the project root. | ||
* | ||
* @constant {string} | ||
* @since 0.1.0 | ||
*/ | ||
const BASE_DIR_ASSETS = `${BASE_DIR_SRC}/assets`; | ||
|
||
/** | ||
* The absolute path of the assets directory for images starting from the project root. | ||
* | ||
* @constant {string} | ||
* @since 0.1.0 | ||
*/ | ||
const BASE_DIR_ASSETS_IMAGES = `${BASE_DIR_ASSETS}/images`; | ||
|
||
/** | ||
* The absolute path of the config base directory starting from the project root. | ||
* | ||
* @constant {string} | ||
* @since 0.1.0 | ||
*/ | ||
const BASE_DIR_CONFIG = `${BASE_DIR_SRC}/config`; | ||
|
||
/** | ||
* The absolute path of the pages base directory starting from the project root. | ||
* | ||
* @constant {string} | ||
* @since 0.1.0 | ||
*/ | ||
const BASE_DIR_PAGES = `${BASE_DIR_SRC}/pages`; | ||
|
||
/** | ||
* The internal type for MDX nodes. | ||
* | ||
* @constant {String} | ||
* @since 0.1.0 | ||
* @see https://github.com/mdx-js/mdx | ||
*/ | ||
const NODE_TYPE_MDX = "Mdx"; | ||
|
||
/** | ||
* Regular expression to match the date of a blog post from the file path. | ||
* | ||
* @constant {RegExp} | ||
* @since 0.1.0 | ||
*/ | ||
const REGEX_BLOG_POST_DATE = /([0-9]+)\/([0-9]+)\/([0-9]+)\/(.+)/; | ||
|
||
module.exports = { | ||
BASE_DIR_ASSETS, | ||
BASE_DIR_ASSETS_IMAGES, | ||
BASE_DIR_CONFIG, | ||
BASE_DIR_CONTENT, | ||
BASE_DIR_PAGES, | ||
NODE_TYPE_MDX, | ||
REGEX_BLOG_POST_DATE | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
/** | ||
* @file Provides internally used data about custom Gatsby GraphQL API nodes. | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.1.0 | ||
*/ | ||
|
||
/** | ||
* The names of the source instance types and their paths relative to the project root path. | ||
* | ||
* @type {Object} | ||
* @since 0.1.0 | ||
*/ | ||
const sourceInstanceTypes = { | ||
blog: { id: "blog", path: "blog" }, | ||
docs: { id: "docs", path: "docs" } | ||
}; | ||
|
||
/** | ||
* The additional fields added to nodes with the Gatsby Node `onCreateNode` API. | ||
* | ||
* @type {Object} | ||
* @see https://gatsbyjs.org/docs/node-apis | ||
* @see https://next.gatsbyjs.org/docs/node-apis/#onCreateNode | ||
* @since 0.1.0 | ||
*/ | ||
const nodeFields = { | ||
/** | ||
* The date a blog post has been created. | ||
*/ | ||
date: { | ||
name: "date", | ||
type: "string", | ||
targetContentSourceTypes: [sourceInstanceTypes.blog.id] | ||
}, | ||
/** | ||
* The content type of the node based on the source instance of the configured `gatsby-source-filesystem` Gatsby | ||
* plugin. | ||
*/ | ||
contentSourceType: { | ||
name: "contentSourceType", | ||
type: "string", | ||
targetContentSourceTypes: [...Object.keys(sourceInstanceTypes).map(name => sourceInstanceTypes[name].id)] | ||
}, | ||
/** | ||
* The slug of the node without the prepended parent route. | ||
*/ | ||
slug: { | ||
name: "slug", | ||
type: "string", | ||
targetContentSourceTypes: [...Object.keys(sourceInstanceTypes).map(name => sourceInstanceTypes[name].id)] | ||
}, | ||
/** | ||
* The relative directory of the node. | ||
*/ | ||
relativeDirectory: { | ||
name: "relativeDirectory", | ||
type: "string", | ||
targetContentSourceTypes: [...Object.keys(sourceInstanceTypes).map(name => sourceInstanceTypes[name].id)] | ||
}, | ||
/** | ||
* The slug of the parent route based on the content source type. | ||
*/ | ||
slugParentRoute: { | ||
name: "slugParentRoute", | ||
type: "string", | ||
targetContentSourceTypes: [...Object.keys(sourceInstanceTypes).map(name => sourceInstanceTypes[name].id)] | ||
} | ||
}; | ||
|
||
module.exports = { nodeFields, sourceInstanceTypes }; |
Oops, something went wrong.