Skip to content

miyaliu666/news-theme

 
 

Repository files navigation

freeCodeCamp.org Social Banner Build Status Pull Requests Welcome first-timers-only Friendly

news-theme

The Ghost for Developer News.

First time using a Ghost theme?

Ghost uses a simple templating language called Handlebars for its themes.

We've documented our default theme pretty heavily so that it should be fairly easy to work out what's going on just by reading the code and the comments. Once you feel comfortable with how everything works, we also have full theme API documentation which explains every possible Handlebars helper and template.

The main files are:

  • default.hbs - The main template file
  • index.hbs - Used for the home page
  • post.hbs - Used for individual posts
  • page.hbs - Used for individual pages
  • tag.hbs - Used for tag archives
  • author.hbs - Used for author archives

One really neat trick is that you can also create custom one-off templates just by adding the slug of a page to a template file. For example:

  • page-about.hbs - Custom template for the /about/ page
  • tag-news.hbs - Custom template for /tag/news/ archive
  • author-ali.hbs - Custom template for /author/ali/ archive

Development

Get Ghost installed locally.

npm install -g ghost
mkdir ghost-local-site
cd ghost-local-site

Currently freeCodeCamp uses Ghost version 2.9.0

ghost install <version> local
ghost start

Follow additional instructions on Ghost's official documentation if are not familiar with its interface.

Now you can clone this project in your theme directory:

cd content/theme/
git clone https://github.com/freeCodeCamp/news-theme.git

The theme styles are compiled using Gulp/PostCSS to polyfill future CSS spec. You'll need Node, and Gulp installed globally. After that, from the theme's root directory:

npm run install
npm run develop

Now you can edit /assets/css/ files, which will be compiled to /assets/built/ automatically.

The zip Gulp task packages the theme files into dist/<theme-name>.zip, which you can then upload to your site.

npm run zip

PostCSS Features Used

  • Autoprefixer - Don't worry about writing browser prefixes of any kind, it's all done automatically with support for the latest 2 major versions of every browser.
  • Variables - Simple pure CSS variables
  • Color Function

SVG Icons

The theme uses inline SVG icons, included via Handlebars partials. You can find all icons inside /partials/icons. To use an icon just include the name of the relevant file, eg. To include the SVG icon in /partials/icons/rss.hbs - use {{> "icons/rss"}}.

You can add your own SVG icons in the same manner.

Copyright & License

Copyright (c) 2019 freeCodeCamp.org - Released under the MIT license.

Releases

No releases published

Packages

No packages published

Languages

  • HTML 53.6%
  • CSS 40.4%
  • JavaScript 6.0%