Coder Social home page Coder Social logo

atlas's Introduction

atlas

网站类,如博客;基于 GatsbyJS

Logs

20210921

添加 siteMetadata

  • gatsby-config.js
const siteMetadata = { ... };

module.exports = {
  
  siteMetadata,
 
  ...

}
  • http://localhost:8000/___graphql
query MyQuery {
  site(siteMetadata: {}) {
    siteMetadata {
      title
      description
      author
      copyright
      contact {
        email
        phone
      }
    }
  }
}

添加 Sourcing Data gatsby-source-filesystem

  • CLI
yarn add gatsby-source-filesystem
  • 增加和 src 目录平级的 seeds 目录,并创建一个 markdown 文件

  • gatsby-config.js

  plugins: [
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'setting',
        path: `${__dirname}/seeds`,
      }
    },

    ...

  ],

  • http://localhost:8000/___graphql
query MyQuery {
  allFile {
    nodes {
      size
      root
      sourceInstanceName
      name
      absolutePath
      dir
      ext
    }
  }
}

添加 Sourcing Data gatsby-source-git

  • CLI
yarn add gatsby-source-git
  • gatsby-config.js
  plugins: [
    
    ...

    {
      resolve: `gatsby-source-git`,
      options: {
        name: `repo-notebook`,
        remote: `https://github.com/we-ready/notebook.git`,
        branch: `master`,
        patterns: [`**/*.md`],
      }
    },

    ...

  ],

  • http://localhost:8000/___graphql
query MyQuery {
  allFile {
    nodes {
      size
      sourceInstanceName
      name
      absolutePath
      ext
    }
  }
}

添加 transformer

  • CLI
yarn add gatsby-transformer-excel gatsby-transformer-remark gatsby-transformer-yaml
  • gatsby-config.js
  plugins: [
    
    ...

    'gatsby-transformer-yaml',
    'gatsby-transformer-excel',
    'gatsby-transformer-remark',
  ]
  • seeds 目录中创建 yaml 文件和 exlx 文件

excel 的第一行,需要填写英文,否则 transformer 将无法识别

  • http://localhost:8000/___graphql
query MyQuery {
  allMarkdownRemark {
    nodes {
      html
      fileAbsolutePath
      frontmatter {
        author
        category
        cover
        id
        created_when(formatString: "YYYY-MM-DD")
      }
    }
  }
}
query MyQuery {
  allSeedsYaml {
    nodes {
      data {
        category
        title
        tree_path
        serial_code
      }
    }
  }
}
query MyQuery {
  allDebuggingXlsxSheet1 {
    nodes {
      age
      name
      id
    }
  }
}

styled-components

  • CLI
yarn add styled-components gatsby-plugin-styled-components babel-plugin-styled-components
  • gatsby-config.js
module.exports = {
  plugins: [
    'gatsby-plugin-styled-components',

    ...
  ],
}

20210918

创建基于 GatsbyJS 的第一个博客模版

参考

需要指定 gatsby-starter-hello-world 代码库,否则,缺省条件创建的工程,可能会因为缺少无法安装的 npm 包而无法正常启动

npx gatsby new blog1 https://github.com/gatsbyjs/gatsby-starter-hello-world

运行开发模式

cd blog1
gatsby develop

执行 yarn start 也一样会执行 gatsby develop,可以参考 package.json

检查运行结果

浏览器打开:http://localhost:8000, http://localhost:8000/___graphql

atlas's People

Contributors

we-ready avatar yunzhiwei avatar

Watchers

 avatar

Forkers

cvgrfd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.