|
1 | 1 | # Hugo Code Block Panel Module |
2 | 2 |
|
3 | | -A simple code block panel for Hugo, [preview it online](https://projects.razonyang.com/hugo-mod-code-block-panel/). |
| 3 | +[](https://github.com/hugomods/code-block-panel/network/dependents) |
| 4 | + |
| 5 | +[](https://github.com/hugomods/code-block-panel/blob/main/LICENSE) |
| 6 | +[](https://github.com/hugomods/code-block-panel/tags) |
4 | 7 |
|
5 | | -## Features |
6 | | - |
7 | | -- Expand toggle. |
8 | | -- Copy code. |
9 | | -- Line number toggle. |
10 | | -- Wrap toggle. |
11 | | - |
12 | | -## Installation |
13 | | - |
14 | | -### 1.Import the Module |
15 | | - |
16 | | -```toml |
17 | | -[[module.imports]] |
18 | | -path = "github.com/hugomods/code-block-panel" |
19 | | -``` |
20 | | - |
21 | | -### 2. Tweak Configuration |
22 | | - |
23 | | -The module requires the following configuration to be set as corresponding values. |
24 | | - |
25 | | -```toml |
26 | | -[markup.highlight] |
27 | | -lineNos = true |
28 | | -lineNumbersInTable = false |
29 | | -``` |
30 | | - |
31 | | -### 3. Import CSS |
32 | | - |
33 | | -You'll need import two SCSS files first. |
34 | | - |
35 | | -```scss |
36 | | -// assets/main.scss |
37 | | -@import "mods/snackbar/scss/index"; // used to show the result of copying code. |
38 | | -@import "mods/code-block-panel/scss/index"; |
39 | | -``` |
40 | | - |
41 | | -> The import paths is relative to the `assets` folder. |
42 | | -
|
43 | | -And then transform it to CSS in partial. |
44 | | - |
45 | | -```go |
46 | | -{{ $css := resources.Get "main.scss" }} |
47 | | -{{ $css = $css | toCSS }} |
48 | | -<link rel="stylesheet" href="{{ $css.RelPermalink }}" /> |
49 | | -``` |
50 | | - |
51 | | -### 4. Import JS |
52 | | - |
53 | | -Import JS by using Hugo Pipe. |
54 | | - |
55 | | -```go |
56 | | -{{ $js := resources.Get "main.ts" | js.Build }} |
57 | | -{{ $codeJS := partialCached "code-block-panel/assets/js-resource" . }} |
58 | | -{{ $js = slice $js $searchJS | resources.Concat "js/main.js" }} |
59 | | -<script src="{{ $js.RelPermalink }}" defer></script> |
60 | | -``` |
61 | | - |
62 | | -Or import JS via partial. |
63 | | - |
64 | | -```go |
65 | | -{{ partialCached "code-block-panel/assets/js" . }} |
66 | | -``` |
67 | | - |
68 | | -## Parameters |
69 | | - |
70 | | -```toml |
71 | | -[params.code_block_panel] |
72 | | -max_lines = 10 |
73 | | -# ... |
74 | | -``` |
75 | | - |
76 | | -| Name | Type | Default | Description |
77 | | -|---|---|---|--- |
78 | | -| `line_nos` | Boolean | `true` | Show/Hide the line numbers by default. |
79 | | -| `max_lines` | Number | `10` | The max visible lines. |
80 | | -| `wrap` | Boolean | `false` | When `true`, wrap the code by default. |
| 8 | +A simple code block panel module for Hugo, which includes expand toggle, code copy button, line number toggle and wrap toggle. Please check out the [documentations](https://hugomods.com/en/docs/code-block-panel/) for details. |
0 commit comments