Skip to content

Commit

Permalink
Use better local testing approach
Browse files Browse the repository at this point in the history
The new testing approach makes it easier to test the theme locally,
without the need to build the theme gem through the Rakefile every time
a change is made to the theme's files, which happens too often.

So, a separate test directory was created with the following files:
  - _config.yml: a modified version of the original _config.yml
  - Gemfile: uses the gemspec method from root directory.
  - .gitignore

The old approach's files were removed:
  - Rakefile
  - docs/_config.dev.yml

The following files were updated; to work with the new approach:
  - _includes/navbar.html
  - docs/pages/docs.md
  - docs/search.json

This approach has only one bug which is that the blog permalink is set
to docs/blog/ instead of blog/; to avoid breaking the pagination.
  • Loading branch information
yousinix committed Jan 21, 2020
1 parent 6f5a579 commit f204b79
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 30 deletions.
7 changes: 0 additions & 7 deletions Rakefile

This file was deleted.

4 changes: 3 additions & 1 deletion _includes/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@

{%- endfor -%}

{%- assign selected_active = false -%}

{% for html_page in filtered_pages %}

{%- if page.url contains html_page.url -%}
{%- if selected_active == false and page.url contains html_page.url -%}
{%- assign active_status = "active" -%}
{%- assign selected_active = true -%}
{%- else -%}
{%- assign active_status = "" -%}
{%- endif -%}
Expand Down
13 changes: 2 additions & 11 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
source "https://rubygems.org"

gem "portfolyou-jekyll-theme", path: "../"
gem "wdm", ">= 0.1.0" if Gem.win_platform?

group :jekyll_plugins do
gem "jekyll-default-layout"
gem "jekyll-gist"
gem "jekyll-github-metadata"
gem "jekyll-include-cache"
gem "jekyll-paginate"
gem "jemoji"
end
gem "github-pages", group: :jekyll_plugins
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
8 changes: 6 additions & 2 deletions docs/pages/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ weight: 5
# About portfolYOU <small class="text-muted">{{ site.github.latest_release.tag_name }}</small>
{:.no_toc}

{%- assign docs = site.static_files | where_exp:"file", "file.path contains '/documentation/'" -%}
{%- assign documentation_dir = "documentation" -%}
{%- assign docs = site.static_files | where_exp: "file", "file.path contains documentation_dir" -%}

{% for doc in docs %}
{% include_relative {{ doc.path | remove: '/pages/' }} %}
{% assign parent_dir = doc.path | split: documentation_dir | first %}
{% assign relative_path = doc.path | remove: parent_dir %}
{% include_relative {{ relative_path }} %}
{% endfor %}

{% include elements/github-edit-footer.html %}
1 change: 1 addition & 0 deletions docs/search.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
layout: null
permalink: /search.json
---
[
{% for post in site.posts %}
Expand Down
12 changes: 12 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Local Site Directories
_site/
.sass-cache/
.jekyll-cache/
.jekyll-metadata

# Ruby Gems
.bundle
Gemfile.lock

# Log Files
*.log
4 changes: 4 additions & 0 deletions test/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gemspec :path => "../"
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
37 changes: 28 additions & 9 deletions docs/_config.dev.yml → test/_config.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
### Site Settings ###
baseurl : "/portfolYOU-dev"
source : ../
collections_dir : docs
data_dir : docs/_data
baseurl : "/portfolYOU-test"
repository : YoussefRaafatNasry/portfolYOU
theme : portfolyou-jekyll-theme


### Navbar Settings ###
nav_exclude:
- blog/tags.html
- blog/page-:num/index.html
- pages/404.html
- pages/index.md
- pages/documentation/**
- docs/blog/tags.html
- docs/blog/page-:num/index.html
- docs/pages/404.html
- docs/pages/index.md
- docs/pages/documentation/**


### Author Info ###
Expand All @@ -22,8 +24,8 @@ author:

### Posts ###
paginate: 6
paginate_path: "/blog/page-:num/"
permalink: /blog/:title
paginate_path: "docs/blog/page-:num/"
permalink: docs/blog/:title


### Collections ###
Expand All @@ -47,3 +49,20 @@ defaults:
type: "elements"
values:
layout: "element"


plugins:
- jekyll-default-layout
- jekyll-gist
- jekyll-github-metadata
- jekyll-include-cache
- jekyll-paginate
- jemoji


exclude:
- test/
- docs/Gemfile
- docs/Gemfile.lock
- docs/_site/
- docs/.sass-cache/

0 comments on commit f204b79

Please sign in to comment.