Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr authored Aug 2, 2021
2 parents b455dc4 + 4575b89 commit 9990647
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 48 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
ignore:
- dependency-name: y18n
versions:
- 4.0.1
- 4.0.2
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ branch_protection:
required_status_checks:
strict: true
contexts:
- "continuous-integration/travis-ci"
- "script/cibuild" # GitHub Actions CI workflow
required_pull_request_reviews:
require_code_owner_reviews: true
10 changes: 7 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
on: push
on:
push:
pull_request:
types: [opened, synchronize]
jobs:
build:
runs-on: ubuntu-latest
name: script/cibuild
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: build
run: script/bootstrap
- name: test
run: script/cibuild
run: script/cibuild
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Gemfile.lock
*.gem
assets/**/*.html
assets/**/*.md
.jekyll-cache
7 changes: 6 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
inherit_gem:
rubocop-github:
- config/default.yml

AllCops:
Exclude:
- _site/**/*
- vendor/**/*

Metrics/LineLength:
Layout/LineLength:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

gemspec
47 changes: 36 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# The Primer theme

[![Build Status](https://travis-ci.org/pages-themes/primer.svg?branch=master)](https://travis-ci.org/pages-themes/primer) [![Gem Version](https://badge.fury.io/rb/jekyll-theme-primer.svg)](https://badge.fury.io/rb/jekyll-theme-primer)
[![.github/workflows/ci.yaml](https://github.com/pages-themes/primer/actions/workflows/ci.yaml/badge.svg)](https://github.com/pages-themes/primer/actions/workflows/ci.yaml) [![Gem Version](https://badge.fury.io/rb/jekyll-theme-primer.svg)](https://badge.fury.io/rb/jekyll-theme-primer)

*Primer is a Jekyll theme for GitHub Pages. You can [preview the theme to see what it looks like](http://pages-themes.github.io/primer), or even [use it today](#usage).*

## Usage
![Thumbnail of Primer](thumbnail.png)

> **_NOTE:_** Primer is now the default theme for GitHub Pages, but you can still specify the theme you're using as below.
## Usage

To use the Primer theme:

1. Add the following to your site's `_config.yml`:

```yml
theme: jekyll-theme-primer
remote_theme: pages-themes/[email protected]
plugins:
- jekyll-remote-theme # add this line to the plugins list if you already have one
```
2. Optionally, if you'd like to preview your site on your computer, add the following to your site's `Gemfile`:
Expand All @@ -22,8 +24,6 @@ To use the Primer theme:
gem "github-pages", group: :jekyll_plugins
```



## Customizing

### Configuration variables
Expand All @@ -38,6 +38,7 @@ description: [A short description of your site's purpose]
Additionally, you may choose to set the following optional variables:

```yml
show_downloads: ["true" or "false" (unquoted) to indicate whether to provide a download URL]
google_analytics: [Your Google Analytics tracking ID]
```

Expand All @@ -55,14 +56,38 @@ If you'd like to add your own custom styles:
```
3. Add any custom CSS (or Sass, including imports) you'd like immediately after the `@import` line

*Note: If you'd like to change the theme's Sass variables, you must set new values before the `@import` line in your stylesheet.*

### Layouts

If you'd like to change the theme's HTML layout:

1. [Copy the original template](https://github.com/pages-themes/primer/blob/master/_layouts/default.html) from the theme's repository<br />(*Pro-tip: click "raw" to make copying easier*)
2. Create a file called `/_layouts/default.html` in your site
3. Paste the default layout content copied in the first step
4. Customize the layout as you'd like
1. For some changes such as a custom `favicon`, you can add custom files in your local `_includes` folder. The files [provided with the theme](https://github.com/pages-themes/primer/tree/master/_includes) provide a starting point and are included by the [original layout template](https://github.com/pages-themes/primer/blob/master/_layouts/default.html).
2. For more extensive changes, [copy the original template](https://github.com/pages-themes/primer/blob/master/_layouts/default.html) from the theme's repository<br />(*Pro-tip: click "raw" to make copying easier*)
3. Create a file called `/_layouts/default.html` in your site
4. Paste the default layout content copied in the first step
5. Customize the layout as you'd like

### Customizing Google Analytics code

Google has released several iterations to their Google Analytics code over the years since this theme was first created. If you would like to take advantage of the latest code, paste it into `_includes/head-custom-google-analytics.html` in your Jekyll site.

### Overriding GitHub-generated URLs

Templates often rely on URLs supplied by GitHub such as links to your repository or links to download your project. If you'd like to override one or more default URLs:

1. Look at [the template source](https://github.com/pages-themes/primer/blob/master/_layouts/default.html) to determine the name of the variable. It will be in the form of `{{ site.github.zip_url }}`.
2. Specify the URL that you'd like the template to use in your site's `_config.yml`. For example, if the variable was `site.github.url`, you'd add the following:
```yml
github:
zip_url: http://example.com/download.zip
another_url: another value
```
3. When your site is built, Jekyll will use the URL you specified, rather than the default one provided by GitHub.

*Note: You must remove the `site.` prefix, and each variable name (after the `github.`) should be indent with two space below `github:`.*

For more information, see [the Jekyll variables documentation](https://jekyllrb.com/docs/variables/).

## Roadmap

Expand All @@ -88,4 +113,4 @@ If you'd like to preview the theme locally (for example, in the process of propo

### Running tests

The theme contains a minimal test suite, to ensure a site with the theme would build successfully. To run the tests, simply run `script/cibuild`. You'll need to run `script/bootstrap` one before the test script will work.
The theme contains a minimal test suite, to ensure a site with the theme would build successfully. To run the tests, simply run `script/cibuild`. You'll need to run `script/bootstrap` once before the test script will work.
10 changes: 10 additions & 0 deletions _includes/head-custom-google-analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% if site.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
9 changes: 9 additions & 0 deletions _includes/head-custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- start custom head snippets, customize with your own _includes/head-custom.html file -->

<!-- Setup Google Analytics -->
{% include head-custom-google-analytics.html %}

<!-- You can set your favicon here -->
<!-- link rel="shortcut icon" type="image/x-icon" href="{{ '/favicon.ico' | relative_url }}" -->

<!-- end custom head snippets -->
11 changes: 1 addition & 10 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

{% seo %}
<link rel="stylesheet" href="{{ "/assets/css/style.css?v=" | append: site.github.build_revision | relative_url }}">
{% include head-custom.html %}
</head>
<body>
<div class="container-lg px-3 my-5 markdown-body">
Expand All @@ -24,15 +25,5 @@ <h1><a href="{{ "/" | absolute_url }}">{{ site.title }}</a></h1>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.1.0/anchor.min.js" integrity="sha256-lZaRhKri35AyJSypXXs4o6OPFTbTmUoltBbDCbdzegg=" crossorigin="anonymous"></script>
<script>anchors.add();</script>
{% if site.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
</body>
</html>
4 changes: 4 additions & 0 deletions _sass/primer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Placeholder file. If your site uses
// @import "{{ site.theme }}";
// Then using this theme with jekyll-remote-theme will work fine.
@import "jekyll-theme-primer";
26 changes: 14 additions & 12 deletions jekyll-theme-primer.gemspec
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# frozen_string_literal: true

Gem::Specification.new do |s|
s.name = 'jekyll-theme-primer'
s.version = '0.5.4'
s.authors = ['GitHub, Inc.']
s.email = ['[email protected]']
s.homepage = 'https://github.com/pages-themes/jekyll-theme-primer'
s.name = "jekyll-theme-primer"
s.version = "0.6.0"
s.authors = ["GitHub, Inc."]
s.email = ["[email protected]"]
s.homepage = "https://github.com/pages-themes/jekyll-theme-primer"
s.summary = "Primer is a Jekyll theme for GitHub Pages based on GitHub's Primer styles"

s.files = `git ls-files -z`.split("\x0").select do |f|
f.match(%r{^(assets|_(includes|layouts|sass)/|(LICENSE|README)((\.(txt|md)|$)))}i)
end

s.platform = Gem::Platform::RUBY
s.license = 'MIT'
s.license = "MIT"

s.add_dependency 'jekyll', '> 3.5', '< 5.0'
s.add_runtime_dependency 'jekyll-github-metadata', '~> 2.9'
s.add_runtime_dependency 'jekyll-seo-tag', '~> 2.0'
s.add_development_dependency 'html-proofer', '~> 3.0'
s.add_development_dependency 'rubocop', '~> 0.50'
s.add_development_dependency 'w3c_validators', '~> 1.3'
s.required_ruby_version = ">= 2.4.0"

s.add_dependency "jekyll", "> 3.5", "< 5.0"
s.add_runtime_dependency "jekyll-github-metadata", "~> 2.9"
s.add_runtime_dependency "jekyll-seo-tag", "~> 2.0"
s.add_development_dependency "html-proofer", "~> 3.0"
s.add_development_dependency "rubocop-github", "~> 0.16"
s.add_development_dependency "w3c_validators", "~> 1.3"
end
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -e

bundle exec jekyll build
bundle exec htmlproofer ./_site --check-html --check-sri
bundle exec rubocop -D
bundle exec rubocop -D --config .rubocop.yml
bundle exec script/validate-html
gem build jekyll-theme-primer.gemspec
10 changes: 5 additions & 5 deletions script/validate-html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'w3c_validators'
require "w3c_validators"

def validator(file)
extension = File.extname(file)
if extension == '.html'
if extension == ".html"
W3CValidators::NuValidator.new
elsif extension == '.css'
elsif extension == ".css"
W3CValidators::CSSValidator.new
end
end
Expand All @@ -18,10 +18,10 @@ def validate(file)
path = File.expand_path "../_site/#{file}", __dir__
results = validator(file).validate_file(path)

return puts 'Valid!' if results.errors.empty?
return puts "Valid!" if results.errors.empty?

results.errors.each { |err| puts err.to_s }
exit 1
end

validate 'index.html'
validate "index.html"

0 comments on commit 9990647

Please sign in to comment.