Skip to content

Commit a973e16

Browse files
authored
Merge pull request #12 from Slavetomints/add/tag-categories-pages
Adding tag and categories pages
2 parents 32360c3 + 67c2d4a commit a973e16

10 files changed

Lines changed: 190 additions & 57 deletions

File tree

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
source "https://rubygems.org"
3+
source 'https://rubygems.org'
44

55
# Specify your gem's dependencies in jekyll-theme-nyx.gemspec
6-
gemspec
6+
gemspec

Rakefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
# frozen_string_literal: true
22

3-
require "rake"
4-
require "fileutils"
3+
require 'rake'
4+
require 'fileutils'
55

6-
GEMSPEC = "jekyll-theme-nyx.gemspec"
6+
GEMSPEC = 'jekyll-theme-nyx.gemspec'
77

88
# Helper to get current version from gemspec
99
def current_version
1010
File.read(GEMSPEC)[/spec\.version\s*=\s*["'](.*?)["']/, 1]
1111
end
1212

13-
GEM_NAME = GEMSPEC.sub(/\.gemspec$/, "")
14-
GEM_FILE = "#{GEM_NAME}-#{current_version}.gem"
13+
GEM_NAME = GEMSPEC.sub(/\.gemspec$/, '')
14+
GEM_FILE = "#{GEM_NAME}-#{current_version}.gem".freeze
1515

16-
desc "Build dummy site to verify theme"
16+
desc 'Build dummy site to verify theme'
1717
task :site do
18-
sh "bundle install"
19-
sh "bundle exec jekyll build"
20-
puts "[+] Dummy site builds successfully"
18+
sh 'bundle install'
19+
sh 'bundle exec jekyll build'
20+
puts '[+] Dummy site builds successfully'
2121
end
2222

23-
desc "Build the gem"
23+
desc 'Build the gem'
2424
task :build do
2525
sh "gem build #{GEMSPEC}"
2626
puts "[+] Built #{GEM_FILE}"
2727
end
2828

29-
desc "Push gem to RubyGems"
29+
desc 'Push gem to RubyGems'
3030
task :push do
3131
sh "gem push #{GEM_FILE}"
3232
end
3333

34-
desc "Create and push git tag"
34+
desc 'Create and push git tag'
3535
task :tag do
3636
sh "git tag v#{current_version}"
3737
sh "git push origin v#{current_version}"
3838
end
3939

40-
desc "Full release: site build, gem build, push, tag"
40+
desc 'Full release: site build, gem build, push, tag'
4141
task release: [:site] do
42-
sh "rake build"
43-
sh "rake push"
44-
sh "rake tag"
42+
sh 'rake build'
43+
sh 'rake push'
44+
sh 'rake tag'
4545
puts "[+] Released #{GEM_NAME} v#{current_version}"
4646
end

_layouts/category.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: default
3+
---
4+
5+
<h1>Category: {{ page.category }}</h1>
6+
7+
<ul class="post-list">
8+
{% for post in page.posts %}
9+
<li class="post-item">
10+
<h2>
11+
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
12+
</h2>
13+
<time>{{ post.date | date: "%B %d, %Y" }}</time>
14+
{% if post.description %}
15+
<p>{{ post.description | strip_html }}</p>
16+
{% endif %}
17+
</li>
18+
{% endfor %}
19+
</ul>

_layouts/tag.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: default
3+
---
4+
5+
<h1>Tag: {{ page.tag }}</h1>
6+
7+
<ul class="post-list">
8+
{% for post in page.posts %}
9+
<li class="post-item">
10+
<h2>
11+
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
12+
</h2>
13+
<time>{{ post.date | date: "%B %d, %Y" }}</time>
14+
{% if post.description %}
15+
<p>{{ post.description | strip_html }}</p>
16+
{% endif %}
17+
</li>
18+
{% endfor %}
19+
</ul>

_plugins/taxonomy_pages.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# frozen_string_literal: true
2+
3+
module Jekyll
4+
class TaxonomyPages < Generator
5+
safe true
6+
7+
def generate(site)
8+
site.tags.each do |tag, posts|
9+
site.pages << TaxonomyPage.new(
10+
site,
11+
site.source,
12+
File.join('tags', tag.downcase.gsub(' ', '-')),
13+
'tag.html',
14+
tag,
15+
posts
16+
)
17+
end
18+
19+
site.categories.each do |category, posts|
20+
site.pages << TaxonomyPage.new(
21+
site,
22+
site.source,
23+
File.join('categories', category.downcase.gsub(' ', '-')),
24+
'category.html',
25+
category,
26+
posts
27+
)
28+
end
29+
end
30+
end
31+
32+
class TaxonomyPage < Page
33+
def initialize(site, base, dir, layout, name, posts)
34+
@site = site
35+
@base = base
36+
@dir = dir
37+
@name = 'index.html'
38+
39+
process(@name)
40+
read_yaml(File.join(base, '_layouts'), layout)
41+
42+
data['posts'] = posts
43+
data[layout.sub('.html', '')] = name
44+
data['title'] = name
45+
end
46+
end
47+
end

_sass/nyx/_layout.scss

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,51 @@ main {
7575
margin: 0;
7676
color: $fg;
7777
line-height: 1.6;
78-
}
78+
}
79+
80+
/* taxonomy lists (tags + categories) */
81+
82+
.taxonomy-list {
83+
list-style: none;
84+
padding: 0;
85+
margin: $space-4 0;
86+
87+
display: grid;
88+
grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
89+
gap: $space-3;
90+
}
91+
92+
.taxonomy-item {
93+
background: $bg-alt;
94+
border: 1px solid rgba(255, 255, 255, 0.06);
95+
border-radius: $radius;
96+
transition: transform 0.15s ease, box-shadow 0.15s ease;
97+
}
98+
99+
.taxonomy-item a {
100+
display: flex;
101+
align-items: center;
102+
justify-content: space-between;
103+
104+
padding: $space-3;
105+
text-decoration: none;
106+
color: $fg;
107+
}
108+
109+
.taxonomy-item:hover {
110+
transform: translateY(-2px);
111+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
112+
}
113+
114+
.taxonomy-name {
115+
font-size: 1rem;
116+
font-weight: 600;
117+
}
118+
119+
.taxonomy-count {
120+
font-size: 0.85rem;
121+
color: $muted;
122+
background: rgba(255, 255, 255, 0.06);
123+
padding: 0.15rem 0.5rem;
124+
border-radius: 999px;
125+
}

_tabs/about.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ order: 4
66

77
<h1>About</h1>
88

9+
This is your "about me" page, where you can add anything about yourself that you wish for the world to know. It uses the default layout rather than the post layout. Feel free to drop your work experience, resume, or just a little blurb about who you are and who you're trying to become.

_tabs/categories.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ order: 2
66

77
<h1>Categories</h1>
88

9-
<div class="categories-list">
9+
<ul class="taxonomy-list categories-list">
1010
{% for category in site.categories %}
11-
{% assign category_name = category[0] %}
12-
<li>
13-
<a href="{{ '/categories/' | append: category_name | slugify | append: '/' | relative_url }}">
14-
{{ category_name }} ({{ category[1].size }})
11+
{% assign name = category[0] %}
12+
<li class="taxonomy-item">
13+
<a href="{{ '/categories/' | append: name | downcase | append: '/' | relative_url }}">
14+
<span class="taxonomy-name">{{ name }}</span>
15+
<span class="taxonomy-count">{{ category[1].size }}</span>
1516
</a>
1617
</li>
1718
{% endfor %}
18-
</div>
19+
</ul>

_tabs/tags.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ order: 3
66

77
<h1>Tags</h1>
88

9-
<div class="tags-list">
9+
<ul class="taxonomy-list tags-list">
1010
{% for tag in site.tags %}
11-
{% assign tag_name = tag[0] %}
12-
<li>
13-
<a href="{{ '/tags/' | append: tag_name | slugify | append: '/' | relative_url }}">
14-
{{ tag_name }} ({{ tag[1].size }})
11+
{% assign name = tag[0] %}
12+
<li class="taxonomy-item">
13+
<a href="{{ '/tags/' | append: name | append: '/' | relative_url }}">
14+
<span class="taxonomy-name">{{ name }}</span>
15+
<span class="taxonomy-count">{{ tag[1].size }}</span>
1516
</a>
1617
</li>
1718
{% endfor %}
18-
</div>
19+
</ul>

jekyll-theme-nyx.gemspec

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
# frozen_string_literal: true
22

33
Gem::Specification.new do |spec|
4-
spec.name = "jekyll-theme-nyx"
5-
spec.version = "0.3.0"
6-
spec.authors = ["Slavetomints"]
7-
spec.email = ["me@slavetomints.com"]
4+
spec.name = 'jekyll-theme-nyx'
5+
spec.version = '0.3.0'
6+
spec.authors = ['Slavetomints']
7+
spec.email = ['me@slavetomints.com']
88

9-
spec.summary = "Simple Jekyll Theme"
9+
spec.summary = 'Simple Jekyll Theme'
1010
spec.description = <<~DESC
11-
Nyx is a dark mode based Jekyll theme focused on readability,
12-
clean typography, and simple blogging.
11+
Nyx is a dark mode based Jekyll theme focused on readability,
12+
clean typography, and simple blogging.
1313
DESC
14-
spec.homepage = "https://github.com/Slavetomints/jekyll-theme-nyx"
15-
spec.license = "MIT"
16-
spec.required_ruby_version = ">= 3.1.0"
14+
spec.homepage = 'https://github.com/Slavetomints/jekyll-theme-nyx'
15+
spec.license = 'MIT'
16+
spec.required_ruby_version = '>= 3.1.0'
1717

18-
spec.metadata["rubygems_mfa_required"] = "true"
19-
spec.metadata["homepage_uri"] = spec.homepage
20-
spec.metadata["source_code_uri"] = spec.homepage
21-
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
22-
spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues"
23-
spec.metadata["documentation_uri"] = "#{spec.homepage}#readme"
24-
spec.metadata["theme"] = "true"
25-
spec.metadata["jekyll_theme"] = "true"
18+
spec.metadata['rubygems_mfa_required'] = 'true'
19+
spec.metadata['homepage_uri'] = spec.homepage
20+
spec.metadata['source_code_uri'] = spec.homepage
21+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
22+
spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
23+
spec.metadata['documentation_uri'] = "#{spec.homepage}#readme"
24+
spec.metadata['theme'] = 'true'
25+
spec.metadata['jekyll_theme'] = 'true'
2626

27-
28-
spec.add_runtime_dependency "jekyll", "~> 4.0"
27+
spec.add_dependency 'jekyll', '~> 4.0'
2928

3029
spec.cert_chain = ['certs/slavetomints.pem']
31-
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
30+
spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/
3231

3332
# Specify which files should be added to the gem when it is released.
3433
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
3534
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
36-
ls.readlines("\x0", chomp: true).select do |f|
37-
# Only include files that actually exist
38-
File.file?(File.join(__dir__, f))
35+
ls.readlines("\x0", chomp: true).select do |f|
36+
# Only include files that actually exist
37+
File.file?(File.join(__dir__, f))
3938
end
4039
end
4140

42-
spec.require_paths = ["lib"]
43-
41+
spec.require_paths = ['lib']
4442
end

0 commit comments

Comments
 (0)