项目作者: aTechGuide

项目描述 :
Gatsby Blog theme powered by MDX and Material UI
高级语言: JavaScript
项目地址: git://github.com/aTechGuide/gatsby-theme-blog-starter.git
创建时间: 2019-07-10T15:53:19Z
项目社区:https://github.com/aTechGuide/gatsby-theme-blog-starter

开源协议:MIT License

下载


gatsby-theme-blog-starter



gatsby-theme-blog-starter is released under the MIT license.


Current npm package version.


Downloads per month on npm.


Total downloads on npm.

PRs welcome!

Follow @atechguide

Gatsby theme for creating super fast, SEO optimized blog powered by MDX and Material UI. See the Live demo

Personal Tech Blog

Performance

Desktop (Home)



Gatsby Theme

Desktop (Blog Page)



Gatsby Theme

Mobile (Home)



Gatsby Theme

Mobile (Blog Page)



Gatsby Theme

✨Features

It provides following functionality out of box

  • Fully optimized for Lighthouse audit
  • Responsive
  • Pagination for blog posts
  • Tags for browsing the content
  • Subscription box (Powered by Mailchimp)
  • Google Structured Data
  • Disqus React for commenting
  • Feed
  • Google Analytics
  • Sitemap

🚀Getting Started

Install

Manually add to you site

npm install --save gatsby-theme-blog-starter

Theme options

Key Default value Description
basePath “/“ Root url for the blog
trackingId “UA-11111XXX-1” Google Analytics Tracking ID
postsPath “posts” Name of the directory from where the posts should be picked
imagesPath “images” Name of the directory from where the images should be picked
postsPerPage “2” Maximum number of posts displayed on each pagination page
mailchimpURL “” Form action URL for MailChimp subscription form. If not provided, subscription box will not be displayed

Example usage

  1. // gatsby-config.js
  2. module.exports = {
  3. plugins: [
  4. {
  5. resolve: "gatsby-theme-blog-starter",
  6. options: {
  7. basePath: "/",
  8. trackingId: "UA-11111XXX-1",
  9. postsPath: "posts",
  10. imagesPath: "images",
  11. postsPerPage: "2",
  12. mailchimpURL: ""
  13. },
  14. },
  15. ],
  16. }

Additional configuration

In addition to the theme options, there are a handful of items you can customize via the siteMetadata object in your site’s gatsby-config.js

  1. // gatsby-config.js
  2. module.exports = {
  3. siteMetadata: {
  4. title: `Blog Title`,
  5. description: `Blog Description`,
  6. author: `Author Name`,
  7. twitterId: `@twitterHandle`,
  8. siteUrl: `site domain name`,
  9. genre: 'Genre', // Used for Google Structured Data
  10. keywords: [`Technology Blog`], // Used for SEO and Google Structured Data
  11. email: `admin@blog.com`, // Contact email Used for Google Structured Data
  12. social: [
  13. 'https://www.facebook.com/aTechGuide/' // Social link used in site schema for Google Structured Data
  14. ],
  15. contactSupport: 'https://www.site.com/support/', // Contact link used in site schema for Google Structured Data
  16. bingId: '', // Support for Bing
  17. menuLinks: [{name: 'Projects', link: '/page/1'}], // Adding Menu bar links
  18. footerLinks: [{name: 'Projects', link: '/page/1'}], // Adding footer links
  19. displayFooterMessage: true, // Enable footer message
  20. comments: 'true' // Enable disable comments
  21. },
  22. }

Folder, Icon and Environment Variables

  • Create posts directory (name of this directory is as per options) and add posts into it
  • Create images directory (name of this directory is as per options) and images into it to be used by queries directly
    • Add icon under images by the name icon.png (name has to be icon)
  • Add .env.* providing disqus shortname as value for key GATSBY_DISQUS_NAME

📝Theme

To override the theme of entire site. You may shadow the theme.js file under example-site/src/gatsby-theme-blog-starter/theme.js

Default Theme

  1. import {deepPurple, red, indigo, yellow, cyan, lightGreen} from '@material-ui/core/colors/';
  2. const theme = {
  3. palette: {
  4. primary: deepPurple,
  5. secondary: red
  6. },
  7. typography: {
  8. fontSize: 16,
  9. h1 : {
  10. fontSize: "3rem",
  11. fontWeight: 500,
  12. color: deepPurple[700]
  13. }
  14. },
  15. button: {
  16. color: "primary",
  17. variant: "contained"
  18. },
  19. postGridItemPadding: '16px',
  20. headingColor: indigo,
  21. highlightOne: yellow,
  22. highlightTwo: cyan,
  23. highlightThree: lightGreen
  24. }
  25. export default theme

Header

Header is customizable with configurations in gatsby-config.js which looks like,

  1. menuLinks: [{name: 'Tags', link: '/tags/'}], // Array of top Navigation bar items. Make sure you have pages corresponding to the value of `link`

You may also completely shadow the header.js inside src/components

Footer is customizable with configurations in gatsby-config.js which looks like,

  1. footerLinks: [{name: 'About', link: '/about/'}, {name: 'Terms of Use', link: '/terms-of-use/'}, {name: 'Privacy Policy', link: '/privacy-policy/'}], //<- Make sure you have pages corresponding to the value of `link`
  2. displayFooterMessage: true, // <- This controls the display of "Powered by Gatsby, Material UI and Netlify"

You may also completely shadow the Footer.js inside src/components

FrontMatter

Frontmatter for pages powered by Mdx looks like

  1. ---
  2. title: SEO friendly Title which will be used in <title> HTML Tag
  3. description: SEO friendly Description which will be used in <meta name="description"> HTML Tag
  4. pagetitle: Title of the Post
  5. summary: Description of the post used in snippet in index page
  6. date: Published Date
  7. update_date: Updated Date
  8. tags:
  9. - technology
  10. label:
  11. - tech
  12. slug: seo-friendly-url
  13. published: true
  14. image: ./path-to-image-used-in-featured-snippet-and-structured-snippet.png
  15. ---