-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDX Integration for docs and blog pages #129
Milestone
Comments
arcticicestudio
added a commit
that referenced
this issue
Mar 3, 2019
Dependencies: - @babel/polyfill (1) - @mdx-js/tag (2) - camelcase (3) - gatsby-image (4) - gatsby-mdx (5) - gatsby-plugin-sharp (6) - gatsby-transformer-sharp (7) Development Dependencies: - rehype-slug (8) - remark-breaks (9) - remark-github (10) - @mdx-js/mdx (11) References: (1) https://www.npmjs.com/package/@babel/polyfill (2) https://www.npmjs.com/package/@mdx-js/tag (3) https://www.npmjs.com/package/camelcase (4) https://www.npmjs.com/package/gatsby-image (5) https://www.npmjs.com/package/gatsby-mdx (6) https://www.npmjs.com/package/gatsby-plugin-sharp (7) https://www.npmjs.com/package/gatsby-transformer-sharp (8) https://www.npmjs.com/package/rehype-slug (9) https://www.npmjs.com/package/remark-breaks (10) https://www.npmjs.com/package/remark-github (11) https://www.npmjs.com/package/@mdx-js/mdx GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 3, 2019
To integrate MDX Gatsby's `onCreateNode` () and `createPages` (2) APIs has been implemented to handle the generation of the GraphQL MDX nodes and the subsequent automated creation of the docs pages and blog posts. References: (1) https://www.gatsbyjs.org/docs/node-apis/#onCreateNode (2) https://www.gatsbyjs.org/docs/node-apis/#createPages GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 3, 2019
To get the best performance and quality for images the awesome Gatsby's awesome support for the high performance Node.js image processing library "Sharp" (1) is used through `gatsby-plugin-sharp` (2), `gatsby-transformer-sharp` (3) and gatsby-image (4). To automatically process all images the transformer provides GraphQL query fragments like `GatsbyImageSharpFluid`. They are used within custom fragments that have been implemented to fit the project structure. References: (1) https://github.com/lovell/sharp (2) https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-sharp (3) https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-sharp (4) https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-image GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 3, 2019
The new name now reflect its purpose as package and not as a React component. GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 3, 2019
This commit initially includes the `Image` (wraps `GatsbyImage`) and `ShinkWidth` component placed in the new atom core package `mdx-elements`. GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 3, 2019
This includes styled components like `PaperSheet` for a uniform docs design. The `MDXProvider` has been configured to map custom HTML components to default Markdown elements and a wrapper component for doc pages has been implemented to define specific styles like "Inter UI" font family. GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 5, 2019
Previously the parsed date was automatically fomratted as UTC resulting in a added time of 00:00:00.000+0000 which conflicts with the way the date will be rendered through the UI. This commit changes the date to only use the "pure" date format (yyyy-MM-dd) without including any time and zone information. GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 5, 2019
This allows to debug Gatsby's development build process like the implemented Node APIs (`gatsby-node-js`) and the configuration (`gatsby-config.js`). GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 9, 2019
This commit initially includes the `Image` (wraps `GatsbyImage`) and `ShinkWidth` component placed in the new atom core package `mdx-elements`. GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 9, 2019
This includes styled components like `PaperSheet` for a uniform docs design. The `MDXProvider` has been configured to map custom HTML components to default Markdown elements and a wrapper component for doc pages has been implemented to define specific styles like "Inter UI" font family. GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 9, 2019
Previously the parsed date was automatically fomratted as UTC resulting in a added time of 00:00:00.000+0000 which conflicts with the way the date will be rendered through the UI. This commit changes the date to only use the "pure" date format (yyyy-MM-dd) without including any time and zone information. GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 9, 2019
This allows to debug Gatsby's development build process like the implemented Node APIs (`gatsby-node-js`) and the configuration (`gatsby-config.js`). GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 9, 2019
To simplify the usage of common and uniform theme mode styles some have been extracted into a new global `styles/shared` package that allows all components ti import them. There are also some "mixins" (functions) that can be used to customize some dynamic/variable attributes of these styles. GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 9, 2019
The last remaining main page is `/blog` which presents an overview of Nord's blog posts in a three-column grid of card components sorted descending by their publish date. Each card consists of an cover image together with the title of the post. The latest post spans over two columns at the top for a nice visual structure and better recognizability. While a one-column card uses a cover image the latest post will use a "banner" that will either be the same image with a larger width, a variant of it or a completly different one. A blog post itself makes use of the MDX features and the custom MDX components mentioned in the paragraph above. To simplify the usage of the "cover" and "banner" image they are be processed with Gatsby's `onCreateNode` (1) API in combination with Gatsby's `mapping` configuration feature (2). This allows to map the paths to the images to a `File` node that will then be handled by the Gatsby image processing plugin workflow (3) also documented in the commit about image handling. Another required node is the `heroImage` field that queries for a `hero.(png|jpg|jpeg)` image that is used as the hero of a blog post. To allow to also use videos in blog posts or even as header a custom `Video` MDX component has been implemented including the optional `heroVideo` and `heroVideoPoster` GraphQL node fields. All together that results in the following required and optional images/videos mapped to specific node fields with reserved file names per blog post directory for simple usage via GraphQL queries: - `bannerImage` <-> `banner.(png|jpg|jpeg)` - The required banner image of a blog post card (used when currently the latest two-column wide post placed on top of the grid). - `coverImage` <-> `cover.(png|jpg|jpeg)` - The required cover image of a one-column blog post. - `heroImage` <-> `hero.(png|jpg|jpeg)` - The required hero image of a blog post. - `heroVideo` <-> `hero.(mp4|webm)` - The optional hero video of a blog post. - `heroVideoPoster` <-> `heroposter.(png|jpg|jpeg)` - The optional poster image of a blog post `heroVideo`. >>> Known Problems To prevent the `unknwon field` GraphQL error during build time (4) (e.g. when there are no blog posts yet) a "dummy"/"placeholder" blog post and docs page will be created. Anyway, this will be removed as soon as there is finally the first blog post and docs page. Later on the project will migrate to the shiny new schema customization API (5). References: (1) https://www.gatsbyjs.org/docs/node-apis/#onCreateNode (2) https://www.gatsbyjs.org/docs/gatsby-config/#mapping-node-types (3) https://www.gatsbyjs.org/docs/working-with-images (4) gatsbyjs/gatsby#3344 (5) https://www.gatsbyjs.org/blog/2019-03-04-new-schema-customization GH-129
arcticicestudio
added a commit
that referenced
this issue
Mar 9, 2019
…ration-docs-blog MDX Integration for docs and blog pages
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue documents the integration of MDX with gatsby-mdx to implement the logic and layout for
/docs
and/blog
pages.Responsive Design
All sections will follow the responsive design concept to adjust the rendered content based on the available width and provide an optimal UX on smaller viewports.
MDX
This issue handles the actual content of the documentation and blog posts.
Gatsby allows to use Markdown for it that comes with the nice side effect that the already existing documentations can simply be adapted and reused, but unfortunately it is limited to it's reduced and simplified syntax.
To also use the great power of React for content and not only layout and design this project will make use of the [MDX specification][gh-mdx-spec], a new language and abstract syntax tree definition.
We will use the official implementation, the fully-featured MDX parser, loader and JSX renderer together with the great Gatsby plugin gatsby-mdx to allow to seamlessly use JSX in Markdown documents by importing components and export metadata or any other ECMAScript compliant data structures like frontmatter.
More details are provided by the official MDX and gatsby-mdx websites that include docs to get started, usage examples and advanced configuration and customization information.
Integration
To integrate MDX Gatsby's
onCreateNode
andcreatePages
APIs will be implemented to handle the generation of the GraphQL MDX nodes and the subsequent automated creation of the docs pages and blog posts.Image Processing
To get the best performance and quality for images Gatsby's awesome support for the high performance Node.js image processing library “Sharp“ will be used through
gatsby-plugin-sharp
,gatsby-transformer-sharp
and gatsby-image.To automatically process all images the transformer provides GraphQL query fragments like
GatsbyImageSharpFluid
. They will be used within custom fragments that'll be implemented to fit the project structure.Custom Content Components
In order to create great documentations and blog posts with interactive elements a new
mdx-elements
atom core package will be created initially including some custom React components that can be imported and placed in MDX based content.To reduce the requirement of imports and "logical Markdown" almost all HTML elements supported by the official Markdown as well as the GitHub Flavored Markdown Specification the
MDXProvider
component will be used to map the project's base components to their specific HTML elements.Docs Pages
The design of docs pages will imitate a paper sheet where the overall styles will use a darker background so that the white paper stands out for a clear and sharp content visualization.
Blog Posts
The last remaining main page is
/blog
which will present an overview of Nord's blog posts in a three-column grid of card components sorted descending by their publish date. Each card will consist of an cover image together with the title of the post. The latest post will span over two columns at the top for a nice visual structure and better recognizability.While a one-column card will use a cover image the latest post will use a banner that will either be the same image with a larger width, a variant of it or a completly different one.
A blog post itself will make use of the MDX features and the custom MDX components mentioned in the paragraph above. To simplify the usage of the cover and banner image they will be processed with Gatsby's
onCreateNode
API in combination with Gatsby'smapping
configuration feature. This allows to map the paths of images to aFile
node that will then be handled by the Gatsby image processing plugin workflow also documented in the Image Processing section above.Another required node will be the
heroImage
field that queries for ahero.(png|jpg|jpeg)
image that'll be used as the hero of a blog post.To also allow the usage of videos in blog posts or even as header a custom
Video
MDX component will be implemented including the optionalheroVideo
andheroVideoPoster
GraphQL node fields.All together that results in the following required and optional images/videos mapped to specific node fields with reserved file names per blog post directory for simple usage via GraphQL queries:
bannerImage
↹banner.(png|jpg|jpeg)
— The required banner image of a blog post card (used when currently the latest two-column wide post placed on top of the grid).coverImage
↹cover.(png|jpg|jpeg)
— The required cover image of a one-column blog post.heroImage
↹hero.(png|jpg|jpeg)
— The required hero image of a blog post.heroVideo
↹hero.(mp4|webm)
— The optional hero video of a blog post.heroVideoPoster
↹heroposter.(png|jpg|jpeg)
— The optional poster image of a blog postheroVideo
.Known Problems
To prevent the
unknwon field
GraphQL error during build time (e.g. when there are no blog posts yet) a dummy/placeholder blog post and docs page will be created.Anyway, they will be removed as soon as there is finally the first blog post and docs page. Later on the project will migrate to the shiny new schema customization API.
Tasks
onCreateNode
andcreatePages
APIs.gatsby-plugin-sharp
,gatsby-transformer-sharp
andgatsby-mdx
including custom GraphQL fragments with theGatsbyImageSharpFluid
type.HTMLElements
package tohtml-elements
to reflect its purpose as package and not as a React component.Image
(wrapsGatsbyImage
),ShinkedWidth
andVideo
placed in the new atom core packagemdx-elements
.DocsPage
andBlogPost
template componentsPaperSheet
styled component for uniform docs designMDXProvider
to map custom HTML components to default Markdown elementsThe text was updated successfully, but these errors were encountered: