Giter Site home page Giter Site logo

scottnonnenberg / blog Goto Github PK

View Code? Open in Web Editor NEW
71.0 3.0 5.0 221.37 MB

The code to generate https://blog.scottnonnenberg.com, a Gatsby-based blog.

Home Page: https://scottnonnenberg.com

License: MIT License

JavaScript 5.28% Shell 0.15% TypeScript 82.51% SCSS 12.06%

blog's Introduction

A fully-featured gatsby-based blog.

Quick start

Get this blog running locally ASAP!

git clone [email protected]:scottnonnenberg/blog.git
cd blog
npm install -g yarn # if you don't already have it
yarn install --offline --pure-lockfile
yarn develop

Now you've got my blog running on http://localhost:8000!

A note about Javascript

I've decided to disable one of the key features of Gatsby for this blog: Javascript on the client side. It increases the download size for your site, but makes intra-site navigations faster. If you'd like your blog to have Javascript enabled, I have a js branch with all of that enabled: https://github.com/scottnonnenberg/blog/compare/main...js

You can also see for yourself what the experience is like with Javascript enabled here: https://blog-js.scottnonnenberg.com

Key settings

gatsbyConfig.ts contains key data you'll want to change first. The location of the blog, author name and details, gatsby plugins, and so on.

mailchimp.ts is the next thing you'll want to change, since it's pointing at my mailing list. The simplest thing to do here is delete this file along with EmailSignup.* and re-add something like it when you're ready.

Develop

This runs gatsby's hot-reloading development server on http://localhost:8000:

yarn develop

To cover more permutations of a given component, Storybook is a great tool. Start it up at https://localhost:6006 like this:

yarn storybook

If you're implementing deeper changes in gatsbyNode.ts, you might want to take a look at the GraphQL schema, or do some test querying. The excellent GraphiQL tool is available while the development-mode side is active at http://localhost:8000/__graphql.

Build

Generate production-ready files to public/ folder:

yarn build

Note: this will generate rss.xml, atom.xml, all.json and recent.json to the root public/ directory along with the site.

Test

Check types, run eslint, and the unit tests with yarn test.

You can use yarn serve to serve static files from public/ at http://localhost:8000 for manual and automated tests. tests/manual.txt has some weird tests you might consider doing if you make some larger changes.

Once you have the static server running you can check for broken links:

# quick run
yarn check-local-links

# these can take some time
yarn check-deep-links
yarn check-links http://localhost:8000/

This project uses GitHub actions for CI. On every push, it will run tests, lint, check types, and check local and deep links: https://github.com/scottnonnenberg/blog/blob/main/.github/workflows/ci.yml

Helper scripts

yarn make-post "The name of your post"

Creates a new markdown file from the template at scripts/util/_postTemplate.md.

yarn clean-post
yarn clean-post 5

By default processes the most recent file. If a number is provided, it will process that many most-recent posts. Removes smart quotes, duplicate links (same text as URL), and all mentions of the blog's domain (taken from gatsbyConfig.ts) to ensure that links are all of the relative form.

Hosting

This blog is hosted on Vercel. It is deployed to production with every push to the main branch. You can see Vercel-specific configuration here, with redirects, cache settings, and forced trailing slashes: https://github.com/scottnonnenberg/blog/blob/main/vercel.json

Contributing

yarn ready is the key thing to run to make sure things are in good shape. It checks types, runs tests, builds the site, and even checks for broken links.

But before you get there, you'll need to make some commits. And this project has some restrictions about how those commits need to be structured. This project uses standard-version to release new versions, automatically updating the version number and changelog based on commit messages in standard format. ghooks and validate-commit-msg are used to ensure all commit messages match the expected format (see package.json for the configuration details).

It takes some getting used to, but this configuration is absolutely worthwhile. A changelog is way easier to understand than the chaos of a raw commit stream, especially with standard-version providing direct links to bugs, commits and commit ranges.

License

The files under posts/ are Copyright 2013-2021, All Rights Reserved.

The rest of the project is under the MIT license:

Copyright (c) 2021 Scott Nonnenberg [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

blog's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

blog's Issues

npm create posts

when trying to do npm run make-post I get the below:

var previousPath = previous.data.path;

Should this work or do I have to give it something else with the command besides just the title?

Thanks

"gatsby build" error,how to fix it?

hi.

root@AR:/usr/local/blog.scottnonnenberg.com# gatsby build
Generating CSS
Generating Static HTML
Failed at generating HTML

/usr/local/blog.scottnonnenberg.com/node_modules/gatsby/dist/bin/cli.js:52
      throw err;
      ^
Error: Error: no window object present
    at render-page.js:52193:16
    at Object.exports.EventEmitter._events (render-page.js:52225:4)
    at __webpack_require__ (render-page.js:30:30)
    at Object.http (render-page.js:52121:13)
    at __webpack_require__ (render-page.js:30:30)
    at Object.<anonymous> (render-page.js:49666:14)
    at Object.<anonymous> (render-page.js:50114:31)
    at __webpack_require__ (render-page.js:30:30)
    at Object.<anonymous> (render-page.js:49344:13)
    at __webpack_require__ (render-page.js:30:30)
root@AR:/usr/local/blog.scottnonnenberg.com#

thanks

Deploy with Netifly

I know from your instructions it mentioned adding in the mailchimp and piwki.js files which I did and this builds locally fine but when trying to build it on Netifly its failing cause of piwik and such, is this normal or a way to get around it until I set that up?

The weird thing is I don't get any errors on local build only when using Netifly:

Failed at generating HTML
1:55:41 PM: /opt/build/repo/node_modules/gatsby/dist/bin/cli.js:52
1:55:41 PM:       throw err;
1:55:41 PM:       ^
1:55:41 PM: Error: ./~/httpreq/lib/httpreq.js
1:55:41 PM: Module not found: Error: Cannot resolve module 'fs' in /opt/build/repo/node_modules/httpreq/lib
1:55:41 PM: resolve module fs in /opt/build/repo/node_modules/httpreq/lib
1:55:41 PM:   looking for modules in /opt/build/repo
1:55:41 PM:     /opt/build/repo/fs doesn't exist (module as directory)
1:55:41 PM:     resolve 'file' fs in /opt/build/repo
1:55:41 PM:       resolve file
1:55:41 PM:         /opt/build/repo/fs doesn't exist
1:55:41 PM:         /opt/build/repo/fs.js doesn't exist
1:55:41 PM:         /opt/build/repo/fs.jsx doesn't exist
1:55:41 PM:         /opt/build/repo/fs.cjsx doesn't exist
1:55:41 PM:         /opt/build/repo/fs.coffee doesn't exist
1:55:41 PM:         /opt/build/repo/fs.json doesn't exist
1:55:41 PM:         /opt/build/repo/fs.less doesn't exist
1:55:41 PM:         /opt/build/repo/fs.css doesn't exist
1:55:41 PM:         /opt/build/repo/fs.scss doesn't exist
1:55:41 PM:         /opt/build/repo/fs.sass doesn't exist
1:55:41 PM:         /opt/build/repo/fs.toml doesn't exist
1:55:41 PM:         /opt/build/repo/fs.yaml doesn't exist

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.