Description#
By default keyboard shortcuts are provided to make it easier to interact with the theme, but it is possible to define specific shortcuts through a minimum of configuration.
For example, it is possible to get the list of available shortcuts using the shortcut Shift + k
.
Define a specific shortcut#
To define a shortcut, follow this process (example with the example (Maj + 1
) shortcut from the theme website):
- Define the general configuration of the shortcut in the site specific configuration file (Cf. highlighted lines below):
1[params] 2 # Website logo file paths 3 logo = "images/logo.png" 4 logoTouch = "images/logoTouch.png" 5 # Image file path displayed during a 404 error 6 image404 = "images/404.gif" 7 # Favicon website file path 8 favicon = "images/favicon.png" 9 # Default layout used for the homepage 10 homeLayout = "onboarding" 11 # Site content order (https://gohugo.io/templates/lists/#order-content) 12 siteContentOrder = "weight" 13 # Activate/Deactivate the table of contents globally (sitewide) 14 toc = true 15 # Activate a global banner on all website pages 16 globalBanner = true 17 # Curent version of the website 18 currentVersion = "latest" 19 # Url of the latest version of the website 20 latestVersionUrl = "https://jgazeau.github.io/shadocs/" 21 # Enforce Link resolution using relref function (https://gohugo.io/content-management/cross-references/) 22 enforceRefrelLinks = true 23 # Disable "Print" button in navbar 24 navbarPrintEntry = false 25 # Disable "QR code" button in navbar 26 navbarQRCodeEntry = false 27 # Disable "Shortcuts" button in navbar 28 navbarSchortcutsEntry = false 29 # Disable "About" button in navbar 30 navbarInfo = false 31 # Keyboard shortcuts list 32 # For each shortcut following keys must be sets: 33 # - keys = [Keyboard shortcuts table](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) 34 # - function = "Javascript function name to call by the shortcut" 35 [params.navbar.shortcuts] 36 # Example shortcut definition 37 [params.navbar.shortcuts.example] 38 keys = ["Shift","1"] 39 function = "scExample" 40 # Taxonomies list 41 # For each taxonomy following keys can be sets: 42 # - icon = "Fontawesome classes associated to the taxonomy" 43 [params.taxonomies] 44 [params.taxonomies.categories] 45 icon = "fa-solid fa-table-cells" 46 # Assets list (https://gohugo.io/hugo-pipes/resource-from-template/) to include 47 # Managed assets: 48 # - sass = [List of SASS files] 49 # - css = [List of CSS files] 50 # - js = [List of javascript files] 51 # - jsModules = [List of javascript modules] 52 # - shortcodes.css = [List of CSS files to includes when the associated shortcode exist in the page content] 53 # - shortcodes.js = [List of javascript files to includes when the associated shortcode exist in the page content] 54 # - shortcodes.jsModules = [List of javascript module files to includes when the associated shortcode exist in the page content] 55 # - fencedcodes.css = [List of CSS files to includes when the associated language of fenced code exist in the page content] 56 # - fencedcodes.js = [List of javascript files to includes when the associated language of fenced code exist in the page content] 57 # - fencedcodes.jsModules = [List of javascript module files to includes when the associated language of fenced code exist in the page content] 58 # 59 [params.includes] 60 sass = [ 61 "sass/file1.sass", 62 "sass/fileX.sass" 63 ] 64 css = [ 65 "css/file1.css", 66 "css/fileX.css" 67 ] 68 js = [ 69 "js/file1.js", 70 "js/fileX.js" 71 ] 72 jsModules = [ 73 "js/modules/file1.js", 74 "js/modules/fileX.js" 75 ] 76 [params.includes.shortcodes.sass] 77 shortcode1 = [ 78 "sass/shortcodes/shortcode1.sass" 79 ] 80 shortcodeX = [ 81 "sass/shortcodes/shortcodeX.sass" 82 ] 83 [params.includes.shortcodes.css] 84 shortcode1 = [ 85 "css/shortcodes/shortcode1.css" 86 ] 87 shortcodeX = [ 88 "css/shortcodes/shortcodeX.css" 89 ] 90 [params.includes.shortcodes.js] 91 shortcode1 = [ 92 "js/shortcodes/shortcode1.js" 93 ] 94 shortcodeX = [ 95 "js/shortcodes/shortcodeX.js" 96 ] 97 [params.includes.shortcodes.jsModules] 98 shortcode1 = [ 99 "js/shortcodes/modules/shortcode1.js" 100 ] 101 shortcodeX = [ 102 "js/shortcodes/modules/shortcodeX.js" 103 ] 104 [params.includes.fencedcodes.css] 105 shortcode1 = [ 106 "css/fencedcodes/shortcode1.css" 107 ] 108 shortcodeX = [ 109 "css/fencedcodes/shortcodeX.css" 110 ] 111 [params.includes.fencedcodes.js] 112 shortcode1 = [ 113 "js/fencedcodes/shortcode1.js" 114 ] 115 shortcodeX = [ 116 "js/fencedcodes/shortcodeX.js" 117 ] 118 [params.includes.fencedcodes.jsModules] 119 shortcode1 = [ 120 "js/fencedcodes/modules/shortcode1.js" 121 ] 122 shortcodeX = [ 123 "js/fencedcodes/modules/shortcodeX.js" 124 ]
- Define shortcut labels that will appear in the shortcut help menu (in the appropriate i18n translation file):
1- id: navbarinfo_content 2 translation: | 3 Website built with [Hugo](https://gohugo.io/) 4- id: navbarinfo_github_main 5 translation: GitHub repository 6- id: navbarinfo_github_download 7 translation: Download 8- id: navbarinfo_github_issue 9 translation: Report an issue 10- id: navbarinfo_github_fork 11 translation: Fork 12# Comma-separated labels associated with the keyboard keys of the shortcut 13- id: example_keys_wording 14 translation: 'Shift,1' 15# Shortcut description 16- id: example_wording 17 translation: 'Display a shortcut example' 18- id: shortcut_example 19 translation: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue.'
- Define the javascript code associated with the shortcut and called through the function defined in step 1:
import { addElementToModal, displayModal, } from './theme/modules/helpers.min.js'; // Function to display a shortcut example window.scExample = scExample; function scExample() { let el = document.createElement('div'); el.classList.add('shortcut-example'); el.innerHTML = '{{- i18n "shortcut_example" -}}'; addElementToModal(el); displayModal(); }