ligarb 0.10.0 → 0.11.0
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 +4 -4
- data/docs/help.md +30 -0
- data/lib/ligarb/config.rb +3 -2
- data/lib/ligarb/template.rb +2 -0
- data/lib/ligarb/version.rb +1 -1
- data/templates/book.html.erb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4da7029fb2f9963b33dc85186479a6b76f279613837c8de76fba3b44f82431c8
|
|
4
|
+
data.tar.gz: '0648d1ad4d05539e4675a835c5970635cd08c560f75de5968cfc9f946371c40c'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b500296a3a1f1d6b0065b40ccdbf3b043ebc8ee6ce8f3278979d2e82f736fc16a2774894f9bce84c757238c09d6f640f2c35524cf924b09b47f20c3bf9eae362
|
|
7
|
+
data.tar.gz: 599ec6de780340aa4c61c7dd7e539363890297102b7a800384089327dbb0dc9cbff2a4e0f1ee808be0b26b37357445d3762a2f8441a932254dd01b05aea816f6
|
data/docs/help.md
CHANGED
|
@@ -199,6 +199,7 @@ The configuration file is a YAML file with the following fields:
|
|
|
199
199
|
| `output_dir` | optional | `"build"` | Output directory relative to book.yml. |
|
|
200
200
|
| `chapter_numbers` | optional | `true` | Show chapter/section numbers (e.g. "1.", "1.1", "1.1.1"). |
|
|
201
201
|
| `style` | optional | — | Path to a custom CSS file relative to book.yml. Loaded after the default styles, so it can override any rule. |
|
|
202
|
+
| `head` | optional | — | Raw HTML injected verbatim at the end of `<head>`. Use it for analytics beacons, search-console verification, custom meta tags, etc. Not sanitized (trusted-author model, like `style`). In a multi-language hub build it is shared across languages (set it once on the hub). See "Custom head HTML (analytics)". |
|
|
202
203
|
| `repository` | optional | — | GitHub repository URL (e.g. "https://github.com/user/repo"). When set, each chapter shows a "View on GitHub" link pointing to `{repository}/blob/HEAD/{path-from-git-root}`. |
|
|
203
204
|
| `ai_generated` | optional | `false` | Mark the book as AI-generated content. When true: adds an "AI Generated" badge in the sidebar header, adds a default disclaimer footer to each chapter, and adds noindex/noai meta tags. The footer text can be overridden with the `footer` field. |
|
|
204
205
|
| `footer` | optional | — | Custom text displayed at the bottom of each chapter. Overrides the default ai_generated disclaimer if both are set. |
|
|
@@ -817,6 +818,35 @@ Example custom.css:
|
|
|
817
818
|
}
|
|
818
819
|
```
|
|
819
820
|
|
|
821
|
+
### Custom head HTML (analytics)
|
|
822
|
+
|
|
823
|
+
GitHub Pages and most static hosts do not report page views (a repository's
|
|
824
|
+
"Insights → Traffic" counts repo visits, not the rendered site). To measure
|
|
825
|
+
traffic, add a small client-side beacon. The `head` field injects raw HTML
|
|
826
|
+
verbatim at the end of `<head>`:
|
|
827
|
+
|
|
828
|
+
```yaml
|
|
829
|
+
head: |
|
|
830
|
+
<script data-goatcounter="https://MYCODE.goatcounter.com/count"
|
|
831
|
+
async src="//gc.zgo.at/count.js"></script>
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
The HTML is embedded as-is (no sanitization — trusted-author model, like
|
|
835
|
+
`style`), so treat it as part of the trusted source. It is not limited to
|
|
836
|
+
analytics: search-console verification tags, a custom `og:image`, or extra
|
|
837
|
+
meta tags work too.
|
|
838
|
+
|
|
839
|
+
[GoatCounter](https://www.goatcounter.com/) is a good fit for a personal site
|
|
840
|
+
— free for non-commercial use, one script tag, no cookies (so no consent
|
|
841
|
+
banner), and a per-page breakdown. [Cloudflare Web Analytics] and Google
|
|
842
|
+
Analytics work the same way; just paste their snippet.
|
|
843
|
+
|
|
844
|
+
[Cloudflare Web Analytics]: https://www.cloudflare.com/web-analytics/
|
|
845
|
+
|
|
846
|
+
In a multi-language hub build, set `head` once on the hub config — it is
|
|
847
|
+
inherited by every language, and the output is a single HTML page, so the
|
|
848
|
+
snippet appears once.
|
|
849
|
+
|
|
820
850
|
### Dark Mode
|
|
821
851
|
|
|
822
852
|
The generated HTML includes a dark mode toggle button (moon icon) in the
|
data/lib/ligarb/config.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Ligarb
|
|
|
11
11
|
# config file that was directly passed to `ligarb build`.
|
|
12
12
|
INHERITABLE_KEYS = %w[author language chapter_numbers style
|
|
13
13
|
repository ai_generated footer bibliography
|
|
14
|
-
github_review site_url].freeze
|
|
14
|
+
github_review site_url head].freeze
|
|
15
15
|
# `description` is intentionally not inheritable: it is usually
|
|
16
16
|
# language-specific, so each translation should set its own.
|
|
17
17
|
|
|
@@ -28,7 +28,7 @@ module Ligarb
|
|
|
28
28
|
attr_reader :title, :author, :language, :output_dir, :base_dir,
|
|
29
29
|
:chapter_numbers, :structure, :style, :repository,
|
|
30
30
|
:ai_generated, :footer, :bibliography, :sources,
|
|
31
|
-
:translations, :github_review, :description, :site_url
|
|
31
|
+
:translations, :github_review, :description, :site_url, :head
|
|
32
32
|
|
|
33
33
|
def initialize(path, parent_data: nil)
|
|
34
34
|
@base_dir = File.dirname(File.expand_path(path))
|
|
@@ -74,6 +74,7 @@ module Ligarb
|
|
|
74
74
|
@footer = data.fetch("footer", nil)
|
|
75
75
|
@bibliography = data.fetch("bibliography", nil)
|
|
76
76
|
@github_review = data.fetch("github_review", nil)
|
|
77
|
+
@head = data.fetch("head", nil)
|
|
77
78
|
@sources = parse_sources(data.fetch("sources", []))
|
|
78
79
|
@structure = parse_structure(data["chapters"])
|
|
79
80
|
@translations = []
|
data/lib/ligarb/template.rb
CHANGED
|
@@ -43,6 +43,7 @@ module Ligarb
|
|
|
43
43
|
b.local_variable_set(:og_locale, og_locale(config.language))
|
|
44
44
|
b.local_variable_set(:og_url, og_url(config))
|
|
45
45
|
b.local_variable_set(:ai_md, ai_md)
|
|
46
|
+
b.local_variable_set(:head_html, config.head)
|
|
46
47
|
|
|
47
48
|
ERB.new(template, trim_mode: "-").result(b)
|
|
48
49
|
end
|
|
@@ -102,6 +103,7 @@ module Ligarb
|
|
|
102
103
|
b.local_variable_set(:og_locale, og_locale(first_config.language))
|
|
103
104
|
b.local_variable_set(:og_url, og_url(first_config))
|
|
104
105
|
b.local_variable_set(:ai_md, nil)
|
|
106
|
+
b.local_variable_set(:head_html, first_config.head)
|
|
105
107
|
|
|
106
108
|
ERB.new(template, trim_mode: "-").result(b)
|
|
107
109
|
end
|
data/lib/ligarb/version.rb
CHANGED
data/templates/book.html.erb
CHANGED