jekyll-theme-centos 2.52.0.beta.101 → 2.52.0.beta.103

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.
@@ -15,8 +15,8 @@ document.addEventListener('DOMContentLoaded', () => {
15
15
  }
16
16
 
17
17
  const config = {
18
- diameter: parseInt(scriptTag.dataset.diameter || '56', 10),
19
- backgroundColor: scriptTag.dataset.backgroundColor || '#A54C93',
18
+ diameter: parseInt(scriptTag.dataset.diameter || '44', 10),
19
+ backgroundColor: scriptTag.dataset.backgroundColor || '#A14F8C',
20
20
  textColor: scriptTag.dataset.textColor || '#ffffff'
21
21
  }
22
22
 
@@ -126,6 +126,9 @@ document.addEventListener('DOMContentLoaded', function () {
126
126
 
127
127
  const handlers = new WeakMap()
128
128
 
129
+ // .copy-btn is a real <button>, so the browser already turns Enter and
130
+ // Space into a native click — one listener covers mouse, keyboard, and
131
+ // assistive-tech activation.
129
132
  document.addEventListener('click', function (e) {
130
133
  const button = e.target.closest('.copy-btn')
131
134
  if (!button) return
@@ -1,12 +1,10 @@
1
- // DataTables Initialization
2
- // Reads configuration from data attributes on this script tag
3
- // Applied via datatable.html.liquid template with data attributes
4
-
5
- // Waits for DOMContentLoaded (like highlight.js) rather than running
6
- // synchronously at defer time, so highlight.js's 'code' class-adding pass
7
- // (also on DOMContentLoaded, registered first since its script tag comes
8
- // first in the document) always runs before DataTables prunes off-page
9
- // rows from the DOM — otherwise their <code> elements never get 'hljs'.
1
+ // Reads its configuration from data attributes datatable.html.liquid sets
2
+ // on this script tag.
3
+
4
+ // Waits for DOMContentLoaded, same as highlight.js, whose script tag comes
5
+ // first in the document and so runs first: this ordering makes sure every
6
+ // <code> element gets its 'hljs' class before DataTables prunes off-page
7
+ // rows from the DOM.
10
8
  document.addEventListener('DOMContentLoaded', () => {
11
9
  if (typeof DataTable === 'undefined') {
12
10
  console.warn('datatable: DataTable not available')
@@ -55,6 +53,14 @@ document.addEventListener('DOMContentLoaded', () => {
55
53
  next: '<i class="fa-solid fa-chevron-right" aria-hidden="true"></i>',
56
54
  last: '<i class="fa-solid fa-angles-right" aria-hidden="true"></i>'
57
55
  }
56
+ },
57
+ // DataTables puts the keyboard-focusable sort trigger on a nested
58
+ // `.dt-column-order` span, not the `<th>` itself, so focus-ring has to
59
+ // go there. initComplete runs once the header row exists, which is
60
+ // the earliest point that span can be selected.
61
+ initComplete: function () {
62
+ this.api().table().header().querySelectorAll('.dt-column-order')
63
+ .forEach(handle => handle.classList.add('focus-ring'))
58
64
  }
59
65
  })
60
66
  })
@@ -1,17 +1,91 @@
1
- // Highlight.js Initialization
2
- // Initializes syntax highlighting on all code blocks with 'hljs' class
3
- // Enables copy-to-clipboard functionality via highlightjs-copy plugin
4
-
5
- // This script tag lives in <head>, before <body> exists. defer normally
6
- // delays execution until after parsing, but consumers that inline this
7
- // file (e.g. monolith bundling) drop the src that defer depends on, so the
8
- // wait for DOMContentLoaded is done explicitly instead of relying on it.
1
+ // Colorizes every <pre><code> block, then gives any block not already
2
+ // inside a preview component the same toolbar (language label + copy
3
+ // button) preview.html.liquid renders for its own code row. This way
4
+ // every code sample looks and behaves the same, whether it's a plain
5
+ // fenced Markdown block or built with the preview component. A wrapped
6
+ // block has no demo row, since a plain fenced block has no demo to show.
7
+
8
+ // Waits for DOMContentLoaded explicitly instead of relying on `defer`:
9
+ // this script tag lives in <head>, and a consumer that inlines the file
10
+ // (e.g. monolith bundling) drops the `src` that `defer` depends on.
9
11
  document.addEventListener('DOMContentLoaded', () => {
10
- if (typeof hljs === 'undefined' || typeof CopyButtonPlugin === 'undefined') {
11
- console.warn('highlight: hljs or CopyButtonPlugin not available')
12
+ if (typeof hljs === 'undefined') {
13
+ console.warn('highlight: hljs not available')
12
14
  return
13
15
  }
14
- document.querySelectorAll('code').forEach(el => el.classList.add('hljs'))
15
- hljs.addPlugin(new CopyButtonPlugin())
16
+
17
+ // Records each block's declared language (a ```language fence becomes a
18
+ // language-<x> class) before hljs.highlightAll() runs. highlightAll()
19
+ // guesses a language for any block missing one, and that guess is often
20
+ // wrong (a short Liquid snippet can easily read as Bash) — only a
21
+ // language the author actually wrote should show as the toolbar label.
22
+ //
23
+ // Scoped to `pre code`: an inline `code` span getting the `.hljs` class
24
+ // would pull in _highlight-theme.scss's block-code color reset, stomping
25
+ // the separate inline-code chip style in _customization.scss.
26
+ const declaredLanguages = new WeakMap()
27
+ document.querySelectorAll('pre code').forEach(el => {
28
+ el.classList.add('hljs')
29
+ const languageClass = [...el.classList].find(c => c.startsWith('language-'))
30
+ if (languageClass) declaredLanguages.set(el, languageClass.replace('language-', ''))
31
+ })
32
+
16
33
  hljs.highlightAll()
34
+
35
+ document.querySelectorAll('pre code.hljs').forEach(codeEl => {
36
+ const preEl = codeEl.parentElement
37
+ if (!preEl || preEl.closest('.preview-code')) return
38
+
39
+ const language = declaredLanguages.get(codeEl) || ''
40
+
41
+ const wrapper = document.createElement('div')
42
+ wrapper.className = 'preview mb-3 border rounded overflow-hidden'
43
+
44
+ // No border-top: the toolbar is always the first row here (a wrapped
45
+ // block has no demo row above it), so a top border would double up
46
+ // against the outer .preview border.
47
+ const toolbar = document.createElement('div')
48
+ toolbar.className = 'preview-toolbar m-0 p-2 border-bottom border-centos-purple-100'
49
+
50
+ if (language) {
51
+ const languageEl = document.createElement('span')
52
+ languageEl.className = 'preview-language small font-monospace text-body-secondary text-uppercase'
53
+ languageEl.textContent = language
54
+ toolbar.appendChild(languageEl)
55
+ }
56
+
57
+ const actions = document.createElement('div')
58
+ actions.className = 'preview-actions'
59
+
60
+ const copyBtn = document.createElement('button')
61
+ copyBtn.setAttribute('type', 'button')
62
+ copyBtn.className = 'copy-btn focus-ring preview-copy'
63
+ copyBtn.setAttribute('data-bs-toggle', 'tooltip')
64
+ copyBtn.setAttribute('data-bs-title', 'Copy code')
65
+ copyBtn.setAttribute('data-copy-value', codeEl.textContent)
66
+ copyBtn.setAttribute('aria-label', 'Copy code')
67
+ copyBtn.innerHTML = '<i class="fa-regular fa-copy"></i>'
68
+ actions.appendChild(copyBtn)
69
+ toolbar.appendChild(actions)
70
+
71
+ const codeRow = document.createElement('div')
72
+ codeRow.className = 'preview-code p-0 m-0'
73
+
74
+ // Matches the p-2 preview.html.liquid puts on its own <pre> — same
75
+ // padding for a code block whether it came from a plain fenced
76
+ // Markdown block or the preview component.
77
+ preEl.classList.add('p-2')
78
+
79
+ preEl.replaceWith(wrapper)
80
+ wrapper.appendChild(toolbar)
81
+ codeRow.appendChild(preEl)
82
+ wrapper.appendChild(codeRow)
83
+
84
+ // init-tooltips.js already made its one-time pass before this button
85
+ // existed, so its tooltip has to be initialized here instead — the
86
+ // same thing preview.html.liquid's server-rendered copy buttons need.
87
+ if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip) {
88
+ new bootstrap.Tooltip(copyBtn)
89
+ }
90
+ })
17
91
  })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-centos
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.52.0.beta.101
4
+ version: 2.52.0.beta.103
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alain Reguera Delgado
@@ -317,6 +317,7 @@ files:
317
317
  - _data/base/navindex_schema.yml
318
318
  - _data/base/ogp.yml
319
319
  - _data/base/ogp_schema.yml
320
+ - _data/base/preview_schema.yml
320
321
  - _data/base/project.yml
321
322
  - _data/base/project_schema.yml
322
323
  - _data/base/script_schema.yml
@@ -365,6 +366,7 @@ files:
365
366
  - _includes/base/navbar.html.liquid
366
367
  - _includes/base/navindex.html.liquid
367
368
  - _includes/base/ogp.html.liquid
369
+ - _includes/base/preview.html.liquid
368
370
  - _includes/base/project.html.liquid
369
371
  - _includes/base/shortcut.html.liquid
370
372
  - _includes/base/social.html.liquid
@@ -379,8 +381,10 @@ files:
379
381
  - _sass/base/_customization.scss
380
382
  - _sass/base/_datatable.scss
381
383
  - _sass/base/_download.scss
384
+ - _sass/base/_highlight-theme.scss
382
385
  - _sass/base/_light-dark.scss
383
386
  - _sass/base/_maps.scss
387
+ - _sass/base/_preview.scss
384
388
  - _sass/base/_theme-colors.scss
385
389
  - _sass/base/_variables.scss
386
390
  - _sass/bootstrap/_accordion.scss