jekyll-vitepress-theme 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66fe5075d52518e812e3a2d8f6e17af3ac03678587c4ba791e577189b725374f
4
- data.tar.gz: 692859f3b2f76e628a59235a565cd4837663e663896d0d0770ac2ab123b2dc62
3
+ metadata.gz: 0a31e9bfb6831ab0c8bbd1376dac09efbf7baaaa592a2da90ddaafe38b2448ee
4
+ data.tar.gz: c038fc1ce886d9b3971492d60faac20071bbd979d1450c2691ddf7df3eac537b
5
5
  SHA512:
6
- metadata.gz: 99c56f6757de3f76dd02188eb5f044b65d431b094153b75ea69c88cfc5af427a3467a3a96cf4e07c5434899b5942a8f00ad7b0886b0db39f816f3fff6ac3548f
7
- data.tar.gz: a6abce7ca7eaf12ec365ad41eb800f7f9ca7d470851670eda401979f7c45f8e499766d7c2fb9aff72702f52fbda95cbb017b4c4f8711f11d7dd19db9de7f44e1
6
+ metadata.gz: faa3c8d2d987ce3e5b394d89a3bfa74058738fdd1e937289173204930ceedf3c38c62358fdb3022efdfeda9f947a1343e7515e4562558a41da482d7513029c9a
7
+ data.tar.gz: 947b2f003a53fab3fb97b7b53b0daabb9542a43f2c259470a9c218b3afff022acbb4cc96782cf578fa39ab21caf9de449c0eed9ce4bde1ffbd2d4ddd0230a7ed
data/README.md CHANGED
@@ -7,6 +7,7 @@ A reusable Jekyll theme gem that reproduces the VitePress default docs experienc
7
7
  - VitePress-style layout structure (top nav, sidebar, outline, doc footer)
8
8
  - Appearance toggle with `auto -> dark -> light`
9
9
  - Local search modal (`/`, `Ctrl/Cmd+K`, `Cmd+K`)
10
+ - Automatic `/search.json` generation for the home page and sidebar collections
10
11
  - Optional GitHub star button with live count (`jekyll_vitepress.github_star`)
11
12
  - Code block copy button, language labels, file-title bars and icons
12
13
  - Page-level "Copy page" split button with raw Markdown copy + plain `.md` view (`jekyll_vitepress.copy_page`, enabled by default)
@@ -1190,8 +1190,12 @@
1190
1190
 
1191
1191
  .VPDocAsideOutline .content {
1192
1192
  position: relative;
1193
+ order: initial;
1194
+ margin: 0;
1193
1195
  border-left: 1px solid var(--vp-c-divider);
1194
- padding-left: 16px;
1196
+ padding: 0 0 0 16px;
1197
+ width: auto;
1198
+ min-width: 0;
1195
1199
  font-size: 13px;
1196
1200
  font-weight: 500;
1197
1201
  }
@@ -1232,13 +1236,12 @@
1232
1236
 
1233
1237
  .VPDocOutlineItem .outline-link {
1234
1238
  display: block;
1235
- line-height: 32px;
1239
+ padding: 6px 0;
1240
+ line-height: 20px;
1236
1241
  font-size: 14px;
1237
1242
  font-weight: 400;
1238
1243
  color: var(--vp-c-text-2);
1239
- white-space: nowrap;
1240
- overflow: hidden;
1241
- text-overflow: ellipsis;
1244
+ overflow-wrap: anywhere;
1242
1245
  transition: color 0.5s;
1243
1246
  }
1244
1247
 
@@ -77,13 +77,11 @@
77
77
  applyMode(mode);
78
78
 
79
79
  function cycleMode() {
80
- if (mode === 'auto') {
81
- mode = 'dark';
82
- } else if (mode === 'dark') {
83
- mode = 'light';
84
- } else {
85
- mode = 'auto';
86
- }
80
+ var isDark = root.classList.contains('dark');
81
+ var nextMode = isDark ? 'light' : 'dark';
82
+ var systemMode = mediaQuery.matches ? 'dark' : 'light';
83
+
84
+ mode = nextMode === systemMode ? 'auto' : nextMode;
87
85
  writeMode(mode);
88
86
  applyModeWithoutTransitions(mode);
89
87
  }
@@ -3,6 +3,75 @@ require 'rouge'
3
3
 
4
4
  module Jekyll
5
5
  module VitePressTheme
6
+ module SearchIndex
7
+ module_function
8
+
9
+ TEMPLATE = <<~LIQUID.freeze
10
+ [
11
+ {% assign first = true %}
12
+ {% assign home_page = site.pages | where: 'url', '/' | first %}
13
+ {% if home_page %}
14
+ {% assign home_excerpt = home_page.content | markdownify | strip_html | strip_newlines | replace: ' ', ' ' | strip | truncate: 2400, '' %}
15
+ {
16
+ "title": {{ home_page.title | default: site.title | strip_html | strip | jsonify }},
17
+ "url": {{ home_page.url | relative_url | jsonify }},
18
+ "content": {{ home_excerpt | jsonify }}
19
+ }
20
+ {% assign first = false %}
21
+ {% endif %}
22
+ {% assign sidebar_groups = site.data.sidebar %}
23
+ {% for group in sidebar_groups %}
24
+ {% assign docs = site[group.collection] | sort: 'nav_order' %}
25
+ {% for doc in docs %}
26
+ {% if doc.title and doc.url %}
27
+ {% unless first %},{% endunless %}
28
+ {% assign excerpt = doc.content | markdownify | strip_html | strip_newlines | replace: ' ', ' ' | strip | truncate: 2400, '' %}
29
+ {
30
+ "title": {{ doc.title | strip_html | strip | jsonify }},
31
+ "url": {{ doc.url | relative_url | jsonify }},
32
+ "content": {{ excerpt | jsonify }}
33
+ }
34
+ {% assign first = false %}
35
+ {% endif %}
36
+ {% endfor %}
37
+ {% endfor %}
38
+ ]
39
+ LIQUID
40
+
41
+ class GeneratedPage < Jekyll::PageWithoutAFile
42
+ def initialize(site)
43
+ super(site, site.source, '', 'search.json')
44
+
45
+ self.content = TEMPLATE
46
+ data['layout'] = nil
47
+ data['permalink'] = '/search.json'
48
+ end
49
+ end
50
+
51
+ def apply(site)
52
+ return if custom_page?(site)
53
+
54
+ site.pages << GeneratedPage.new(site)
55
+ end
56
+
57
+ def custom_page?(site)
58
+ site.pages.any? { |page| search_index_path?(page.path) || search_index_url?(page.url) } ||
59
+ site.static_files.any? { |file| search_index_path?(file.path) || search_index_url?(file.relative_path) }
60
+ end
61
+
62
+ def search_index_path?(value)
63
+ return false unless value
64
+
65
+ Pathname.new(value.to_s).basename.to_s == 'search.json'
66
+ rescue ArgumentError
67
+ false
68
+ end
69
+
70
+ def search_index_url?(value)
71
+ value.to_s.strip == '/search.json'
72
+ end
73
+ end
74
+
6
75
  module LastUpdated
7
76
  module_function
8
77
 
@@ -160,6 +229,7 @@ end
160
229
  Jekyll::Hooks.register :site, :post_read do |site|
161
230
  Jekyll::VitePressTheme::VersionLabel.apply(site)
162
231
  Jekyll::VitePressTheme::RougeStyles.apply(site)
232
+ Jekyll::VitePressTheme::SearchIndex.apply(site)
163
233
  end
164
234
 
165
235
  Jekyll::Hooks.register :documents, :pre_render do |document, payload|
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module VitePressTheme
3
- VERSION = "1.2.1".freeze
3
+ VERSION = "1.2.3".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-vitepress-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carmine Paolino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-25 00:00:00.000000000 Z
11
+ date: 2026-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll