Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 9fcaaf6

Browse files
committed
Add responsive embed helper
1 parent 5cb24d6 commit 9fcaaf6

File tree

4 files changed

+121
-43
lines changed

4 files changed

+121
-43
lines changed

README.md

+69-23
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ If you're running Jekyll v3.5+ and self-hosting you can quickly install the them
2121

2222
### Ruby Gem Method
2323

24-
1. Add this line to your Jekyll site's `Gemfile` (or [create one](example/Gemfile):
24+
1. Add this line to your Jekyll site's `Gemfile` (or [create one](example/Gemfile)):
2525

2626
```ruby
2727
gem "jekyll-theme-so-simple"
@@ -71,7 +71,6 @@ If you forked or downloaded the [`so-simple-theme` repo](https://github.com/mmis
7171
* `CHANGELOG.md`
7272
* `Gemfile`
7373
* `jekyll-theme-so-simple.gemspec`
74-
* `LICENSE`
7574
* `Rakefile`
7675
* `README.md`
7776
* `screenshot.png`
@@ -91,7 +90,7 @@ To check which version you are currently using, view the source of your built si
9190
-->
9291
```
9392

94-
At the top of every `.html` file, `/assets/css/main.css`, and `/assets/js/main.js`.
93+
This will be at the top of every `.html` file, `/assets/css/main.css`, and `/assets/js/main.js`.
9594

9695
### Ruby Gem
9796

@@ -131,8 +130,7 @@ Depending on the amount of customizations you've made after forking, there's lik
131130

132131
### Update Files Manually
133132

134-
Another way of dealing with updates is [downloading the theme](https://github.com/mmistakes/so-simple-theme/archive/master.zip) --- replacing your layouts, includes, and assets with the newer ones manually. To be sure that you don't miss any changes it's probably a good idea to review
135-
the theme's [commit history](https://github.com/mmistakes/so-simple-theme/commits/master) to see what's changed.
133+
Another way of dealing with updates is [downloading the theme](https://github.com/mmistakes/so-simple-theme/archive/master.zip) --- replacing your layouts, includes, and assets with the newer ones manually. To be sure that you don't miss any changes review the theme's [commit history](https://github.com/mmistakes/so-simple-theme/commits/master) to see what has changed.
136134

137135
Here's a quick checklist of the important folders/files you'll want to be mindful of:
138136

@@ -154,7 +152,7 @@ Here's a quick checklist of the important folders/files you'll want to be mindfu
154152

155153
Layouts, includes, Sass partials, and data files are all placed in their default locations. Stylesheets and scripts can be found in `assets`, and a few development related files in the project's root directory.
156154

157-
**Please note:** If you installed So Simple via the Ruby Gem or remote theme methods, theme files found in `/_layouts`, `/_includes`, `/_sass`, and `/assets` will be missing. This is normal as they are bundled with the [`jekyll-theme-so-simple`](https://rubygems.org/gems/jekyll-theme-so-simple) gem.
155+
**Please note:** If you installed So Simple via the Ruby Gem or remote theme methods, theme files found in `/_layouts`, `/_includes`, `/_sass`, and `/assets` will be missing from your project. This is normal as they are bundled with the [`jekyll-theme-so-simple`](https://rubygems.org/gems/jekyll-theme-so-simple) gem.
158156

159157
```
160158
├── _data # data files
@@ -185,7 +183,7 @@ After creating a `Gemfile` and installing the theme you'll need to add and edit
185183

186184
Using the `jekyll new` command will get you up and running the quickest.
187185

188-
Edit `_config.yml` following the guide below and then create `_data/text.yml` as instructed earlier.
186+
Edit your `Gemfile` and `_config.yml` files following the [installation guide](#installation) above and [configuration guide](#configuring) below, then create `_data/text.yml` as instructed earlier.
189187

190188
## Configuring
191189

@@ -214,13 +212,13 @@ Properly setting the locale is important for associating localized text found in
214212

215213
The base hostname and protocol for your site. If you're hosting with GitHub Pages this will be something like `url: "https://github.io.mmistakes"` or `url: "https://your-site.com"` if you have a custom domain name.
216214

217-
GitHub Pages now [forces `https://` for new sites](https://help.github.com/articles/securing-your-github-pages-site-with-https/) so be mindful of that when setting your URL to avoid mixed-content warnings.
215+
GitHub Pages now [forces `https://` for new sites](https://help.github.com/articles/securing-your-github-pages-site-with-https/), so be mindful of that when setting your URL to avoid mixed-content warnings.
218216

219217
**Note:** Jekyll overrides the value of `url` with `http://localhost:4000` when running `jekyll serve` locally in development. If you want to avoid this behavior set `JEKYLL_ENV=production` to [force the environment](http://jekyllrb.com/docs/configuration/#specifying-a-jekyll-environment-at-build-time) to production.
220218

221219
### Site Base URL
222220

223-
This option causes all kinds of confusion in the Jekyll community. If you're not hosting your site as a GitHub Pages Project or in a subfolder (e.g., `/blog`), then don't mess with it.
221+
This option causes all kinds of confusion in the Jekyll community. If you're not hosting your site as a [GitHub Project Page](https://help.github.com/articles/user-organization-and-project-pages/) or in a subfolder (e.g., `/blog`), then don't mess with it.
224222

225223
In the case of the **So Simple** demo site it's hosted on GitHub at <https://mmistakes.github.io/so-simple-theme>. To correctly set this base path I'd use `url: "https://mmistakes.github.io"` and `baseurl: "/so-simple-theme"`.
226224

@@ -230,6 +228,8 @@ For more information on how to properly use `site.url` and `site.baseurl` as int
230228

231229
To use the example values above the following image path of `{{ '/images/my-image.jpg' | relative_url }}` would output correctly as `http://localhost:4000/blog/images/my-image.jpg`.
232230

231+
Without the `relative_url` filter that asset path would be missing `/blog` and you'd have a broken image on your page.
232+
233233
### Date Format
234234

235235
You can change the default date format by specifying `date_format` in `_config.yml`. It accepts any of the standard [Liquid date formats](http://shopify.github.io/liquid/filters/date/).
@@ -251,7 +251,7 @@ words_per_minute: 200
251251

252252
### Mathematics
253253

254-
Enable [MathJax](https://www.mathjax.org) (a JavaScript display engine for mathematics) site-wide with `mathjax: true`.
254+
Enable [**MathJax**](https://www.mathjax.org) (a JavaScript display engine for mathematics) site-wide with `mathjax: true`.
255255

256256
### Google Fonts
257257

@@ -280,11 +280,11 @@ $description-font-family: $serif-font-family;
280280
$meta-font-family: $serif-font-family;
281281
```
282282

283-
See stylesheet documentation below for more information on overriding the theme's default variables.
283+
See [stylesheet documentation](#customizing-sass-scss) below for more information on overriding the theme's default variables.
284284

285285
### Pagination
286286

287-
Break up the main listing of posts on the home page into smaller lists across multiple pages by [enabling pagination](http://jekyllrb.com/docs/pagination/).
287+
Break up the main listing of posts on the home page across multiple pages by [enabling pagination](http://jekyllrb.com/docs/pagination/).
288288

289289
1. Include the [`jekyll-paginate`][jekyll-paginate] plugin in your `Gemfile`.
290290

@@ -308,6 +308,16 @@ Break up the main listing of posts on the home page into smaller lists across mu
308308
paginate: true
309309
```
310310

311+
### Search
312+
313+
To index the full content of your documents for use in a [search page](#layout-search), set `search_full_content` to `true` in `_config.yml`:
314+
315+
```yaml
316+
search_full_content: true
317+
```
318+
319+
**Note:** Large amounts of posts will increase the size of the search index, impacting page load performance. Setting `search_full_content` to `false` (the default) restricts indexing to the first 50 words of body content.
320+
311321
### Taxonomy Pages
312322

313323
By default, category and tags added to a post are not linked to taxonomy archive pages. To enable this behavior and link to pages with posts grouped by category or tag, add the following:
@@ -317,7 +327,7 @@ category_archive_path: "/categories/#"
317327
tag_archive_path: "/tags/#"
318328
```
319329

320-
These paths should mimic the permalinks used for your [**category**](#layout-categories) and [**tag archive**](#layout-tags) pages. The `#` at the end is necessary to target the correct taxonomy section on the page.
330+
These paths should mimic the permalinks used for your [**categories**](#layout-categories) and [**tags archive**](#layout-tags) pages. The `#` at the end is necessary to target the correct taxonomy section on the pages.
321331

322332
For example if you were to create `categories.md` with the following front matter:
323333

@@ -366,7 +376,7 @@ For more configuration options be sure to consult the documentation for:
366376

367377
## Layouts
368378

369-
This theme provides the following layouts, which you can use by setting the `layout` [Front Matter](https://jekyllrb.com/docs/frontmatter/) on each page, like so:
379+
This theme provides the following layouts, which you can use by setting the `layout` [front matter](https://jekyllrb.com/docs/frontmatter/) on each page, like so:
370380

371381
```yaml
372382
---
@@ -384,7 +394,7 @@ This layout accommodates the following front matter:
384394

385395
| Name | Type | Description |
386396
| ---- | ----- | ---------- |
387-
| `image` | String | Path to a large image associated with the post. Also used for OpenGraph, Twitter Cards, and site feed thumbnail if enabled. [Suggested sizes](#images) |
397+
| `image` | String | Path to a large image associated with the post. Also used for [OpenGraph](http://ogp.me/), [Twitter Cards](https://dev.twitter.com/cards), and site feed thumbnail if enabled. [Suggested image sizes](#images). |
388398
| `image.path` | String | Same as above. Used when a `thumbnail` or `caption` needs to be assigned to the `image` object as well. |
389399
| `image.caption` | String | Describes the image or provides credit. Markdown is allowed. |
390400
| `author` | Object or string | Specify a post's author `name`, `picture`, `twitter`, `links`, etc. |
@@ -465,7 +475,7 @@ differences.
465475
* Disqus comments are omitted.
466476
* Next/Previous post navigation links omitted.
467477

468-
The page layout forms the base for several other layouts like `home`, `posts`, `categories`, `tags`, and `search`.
478+
The page layout forms the base for several other layouts like [`home`](#layout-home), [`posts`](#layout-posts), [`categories`](#layout-categories), [`tags`](#layout-tags), [`collection`](#layout-collection), [`category`](#layout-category), [`tag`](#layout-tag), and [`search`](#layout-search).
469479

470480
### `layout: home`
471481

@@ -474,14 +484,15 @@ addition of the following:
474484

475485
```yaml
476486
paginate: true # enables pagination loop, see section above for additional setup
487+
entries_layout: # list (default), grid
477488
```
478489

479490
When not enabled the page defaults to showing the latest 10 posts. To change the amount of posts shown, you can edit or override the `limit` value in [`/_includes/posts-limit.html`](_includes/posts-limit.html).
480491

481492
```liquid
482-
{%- for entry in site.posts limit: 10 -%}
493+
{% for entry in site.posts limit: 10 %}
483494
{% include entry.html %}
484-
{%- endfor -%}
495+
{% endfor %}
485496
```
486497

487498
By default, posts are shown in a list view. To change to a grid view add `entries_layout: grid` to the page's front matter.
@@ -533,7 +544,7 @@ taxonomy: # category name
533544
entries_layout: # list (default), grid
534545
```
535546

536-
By default, documents are shown in a list view. To change to a grid view add `entries_layout: grid` to the page's front matter.
547+
By default, posts are shown in a list view. To change to a grid view add `entries_layout: grid` to the page's front matter.
537548

538549
To create a page showing all posts assigned to the category `foo` you'd create `foo.md` in the root of your project and add this front matter:
539550

@@ -553,7 +564,7 @@ taxonomy: # tag name
553564
entries_layout: # list (default), grid
554565
```
555566

556-
By default, documents are shown in a list view. To change to a grid view add `entries_layout: grid` to the page's front matter.
567+
By default, posts are shown in a list view. To change to a grid view add `entries_layout: grid` to the page's front matter.
557568

558569
To create a page showing all posts assigned to the tag `foo bar` you'd create `foo-bar.md` in the root of your project and add this front matter:
559570

@@ -566,7 +577,23 @@ taxonomy: foo bar
566577

567578
### `layout: search`
568579

569-
This layout displays a search form.
580+
This layout displays a search form and displays related pages based on the query.
581+
582+
Page content index: `title`, `excerpt`, `content` (when enabled), `categories`, `tags`, and `url`.
583+
584+
If you would like to exclude specific pages/posts from the search index set the search flag to `false` in their front matter.
585+
586+
```yaml
587+
search: false
588+
```
589+
590+
To index the full content of your documents set `search_full_content` to `true` in `_config.yml`:
591+
592+
```yaml
593+
search_full_content: true
594+
```
595+
596+
**Note:** Large amounts of posts will increase the size of the search index, impacting page load performance. Setting `search_full_content` to `false` (the default) restricts indexing to the first 50 words of body content.
570597

571598
## Images
572599

@@ -582,10 +609,10 @@ Suggested image sizes in pixels are as follows:
582609

583610
## Theme Text
584611

585-
To change text found throughout the theme copy the following
612+
To change text found throughout the theme, copy the following
586613
[`/_data/theme.yml`](_data/text.yml) file and customize as necessary.
587614

588-
When adding new texts be sure the keys match these [language/country codes](<https://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx>) that may be used for [`site.locale`](#site-locale).
615+
When adding new texts be sure the keys match these [language/country codes](<https://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx>), that may be used for [`site.locale`](#site-locale).
589616

590617
## Navigation
591618

@@ -693,6 +720,25 @@ By default the copyright inserts the current year, [`site.title`](#site-title),
693720
copyright: "This site is made with <3 by *me, myself, and I*."
694721
```
695722

723+
## Helpers
724+
725+
You can think of these Jekyll helpers as shortcodes. Since GitHub Pages doesn't allow most plugins --- [custom tags](https://jekyllrb.com/docs/plugins/#tags) are out. Instead the theme leverages [**includes**](https://jekyllrb.com/docs/templates/#includes) to do something similar.
726+
727+
### Responsive Embed
728+
729+
Embed a video from YouTube/Vimeo or any other `iframe` content that responsively sizes to fit the width of its parent.
730+
731+
| Parameter | Required | Description |
732+
| --------- | -------- | ----------- |
733+
| `url` | Yes | Video or iframe's URL e.g., `https://www.youtube.com/watch?v=-PVofD2A9t8` |
734+
| `ratio` | Optional | Ratio of the video or iframe content. `21:9`, `16:9`, `4:3`, `1:1`. If a ratio is not assigned `16:9` is used. |
735+
736+
**Example:**
737+
738+
```html
739+
{% include responsive-embed url="https://www.youtube.com/watch?v=-PVofD2A9t8" ratio="16:9" %}
740+
```
741+
696742
## Migration Guide
697743

698744
So Simple 3 is a major rewrite of the entire theme. The most notable changes are summarized below, followed by more specific changes.

_includes/responsive-embed

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{%- case include.ratio -%}
2+
{%- when '21:9' -%}
3+
{%- assign ratio_class = 'responsive-embed-21by9' -%}
4+
{%- when '16:9' -%}
5+
{%- assign ratio_class = 'responsive-embed-16by9' -%}
6+
{%- when '4:3' -%}
7+
{%- assign ratio_class = 'responsive-embed-4by3' -%}
8+
{%- when '1:1' -%}
9+
{%- assign ratio_class = 'responsive-embed-1by1' -%}
10+
{%- else -%}
11+
{%- assign ratio_class = 'responsive-embed-16by9' -%}
12+
{%- endcase -%}
13+
14+
<div class="responsive-embed {{ ratio_class }}">
15+
<iframe src="{{ include.url }}" frameborder="0" allowfullscreen></iframe>
16+
</div>

_sass/so-simple/utilities/_responsive-embed.scss

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
Credit: Nicolas Gallagher and SUIT CSS.
44
55
<!-- 16:9 aspect ratio -->
6-
<div class="embed-responsive embed-responsive-16by9">
7-
<iframe class="embed-responsive-item" src="..."></iframe>
6+
<div class="responsive-embed responsive-embed-16by9">
7+
<iframe class="responsive-embed-item" src="..."></iframe>
88
</div>
99
1010
<!-- 4:3 aspect ratio -->
11-
<div class="embed-responsive embed-responsive-4by3">
12-
<iframe class="embed-responsive-item" src="..."></iframe>
11+
<div class="responsive-embed responsive-embed-4by3">
12+
<iframe class="responsive-embed-item" src="..."></iframe>
1313
</div>
1414
========================================================================== */
1515

16-
.embed-responsive {
16+
.responsive-embed {
1717
display: block;
1818
position: relative;
1919
width: 100%;
@@ -26,7 +26,7 @@
2626
content: "";
2727
}
2828

29-
.embed-responsive-item,
29+
.responsive-embed-item,
3030
iframe,
3131
embed,
3232
object,
@@ -41,25 +41,25 @@
4141
}
4242
}
4343

44-
.embed-responsive-21by9 {
44+
.responsive-embed-21by9 {
4545
&::before {
4646
padding-top: percentage(9 / 21);
4747
}
4848
}
4949

50-
.embed-responsive-16by9 {
50+
.responsive-embed-16by9 {
5151
&::before {
5252
padding-top: percentage(9 / 16);
5353
}
5454
}
5555

56-
.embed-responsive-4by3 {
56+
.responsive-embed-4by3 {
5757
&::before {
5858
padding-top: percentage(3 / 4);
5959
}
6060
}
6161

62-
.embed-responsive-1by1 {
62+
.responsive-embed-1by1 {
6363
&::before {
6464
padding-top: percentage(1 / 1);
6565
}

example/_posts/2010-06-02-post-video-youtube.md

+26-10
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,41 @@ categories:
44
- Post Formats
55
tags:
66
- Post Formats
7-
last_modified_at: 2017-03-23T15:33:37-04:00
7+
last_modified_at: 2018-02-01T12:54:35-05:00
88
---
99

10-
<div class="embed-responsive embed-responsive-16by9">
11-
<iframe width="640" height="360" src="https://www.youtube-nocookie.com/embed/l2Of1-d5E5o?controls=0&amp;" frameborder="0" allowfullscreen></iframe>
12-
</div>
13-
1410
This post tests YouTube video embeds.
1511

16-
Simply wrap embeds with a `<div>` element and the appropriate classes:
12+
{% include responsive-embed url="https://www.youtube-nocookie.com/embed/l2Of1-d5E5o?controls=0&amp;" %}
13+
14+
Simply use the `responsive-embed` helper include like so:
15+
16+
```html
17+
{% raw %}{% include responsive-embed url="https://www.youtube.com/watch?v=-PVofD2A9t8" ratio="16:9" %}{% endraw %}
18+
```
19+
20+
Or wrap embeds with a `<div>` element and the appropriate classes:
1721

1822
```html
23+
<!-- 21:9 aspect ratio -->
24+
<div class="responsive-embed responsive-embed-21by9">
25+
<iframe class="responsive-embed-item" src="..."></iframe>
26+
</div>
27+
1928
<!-- 16:9 aspect ratio -->
20-
<div class="embed-responsive embed-responsive-16by9">
21-
<iframe class="embed-responsive-item" src="..."></iframe>
29+
<div class="responsive-embed responsive-embed-16by9">
30+
<iframe class="responsive-embed-item" src="..."></iframe>
2231
</div>
2332

2433
<!-- 4:3 aspect ratio -->
25-
<div class="embed-responsive embed-responsive-4by3">
26-
<iframe class="embed-responsive-item" src="..."></iframe>
34+
<div class="responsive-embed responsive-embed-4by3">
35+
<iframe class="responsive-embed-item" src="..."></iframe>
36+
</div>
37+
38+
<!-- 1:1 aspect ratio -->
39+
<div class="responsive-embed responsive-embed-1by1">
40+
<iframe class="responsive-embed-item" src="..."></iframe>
2741
</div>
2842
```
43+
44+

0 commit comments

Comments
 (0)