docs: use a propertylist to document shortcode attributes (#732)

This commit is contained in:
Robert Kaussow 2023-10-27 21:38:23 +02:00 committed by GitHub
parent 76ef8f147c
commit 83469c437f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 256 additions and 94 deletions

View File

@ -4,11 +4,20 @@ title: Buttons
Buttons are styled links that can lead to local page or external link.
<!-- prettier-ignore-start -->
## Usage
<!-- prettier-ignore -->
```tpl
{{</* button relref="/" [class="...", size="large|regular"] */>}}Get Home{{</* /button */>}}
{{</* button href="https://github.com/thegeeklab/hugo-geekdoc" */>}}Contribute{{</* /button */>}}
```
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-buttons sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Example

View File

@ -4,12 +4,6 @@ title: Columns
The Columns shortcode can be used to organize content side-by-side (horizontally) for better readability.
## Attributes
| Name | Description | default |
| --------------- | ------------------------------------------------ | ------- |
| size (optional) | size of the first column (small\|regular\|large) | regular |
## Usage
```html
@ -29,11 +23,19 @@ Dolor sit, sumo unique argument um no ...
{{</* /columns */>}}
```
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-columns sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Example
{{< columns >}}
## Left
### Left
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts
@ -42,14 +44,14 @@ copious quo ad. Stet probates in duo.
<--->
## Mid Content
### Mid Content
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re.
<--->
## Right Content
### Right Content
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts

View File

@ -4,40 +4,38 @@ title: Expand
Expand shortcode can help to decrease clutter on screen by hiding part of text. Expand content by clicking on it.
## Example
## Usage
### Default
<!-- prettier-ignore-start -->
```tpl
{{</* expand */>}}
## Markdown content
### Markdown content
Dolor sit, sumo unique ...
{{</* /expand */>}}
```
<!-- prettier-ignore-end -->
It is also possible to use a custom label and symbol.
<!-- prettier-ignore-start -->
```tpl
{{</* expand "Custom Label" "..." */>}}
### More markdown
Dolor sit, sumo unique ...
{{</* /expand */>}}
```
## Example
{{< expand >}}
## Markdown content
### Markdown content
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture. Ornateness bland it ex enc, est yeti am bongo detract re.
{{< /expand >}}
### With Custom Label
<!-- prettier-ignore-start -->
```tpl
{{</* expand "Custom Label" "..." */>}}
## Markdown content
Dolor sit, sumo unique ...
{{</* /expand */>}}
```
<!-- prettier-ignore-end -->
{{< expand "Custom Label" "..." >}}
## More markdown
### More markdown
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts

View File

@ -4,14 +4,6 @@ title: Hints
Hint shortcode can be used as hint/alerts/notification block.
## Attributes
| Name | Description | default |
| ---------------- | -------------------------------------------------------------------------------- | --------- |
| type | hint type | note |
| icon (optional) | custom icon to use,need to be an icon from an [SVG sprite](/features/icon-sets/) | undefined |
| title (optional) | hint title | undefined |
## Usage
<!-- prettier-ignore-start -->
@ -24,6 +16,14 @@ Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclima
```
<!-- prettier-ignore-end -->
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-hints sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Example
{{< hint type=note >}}

View File

@ -4,15 +4,17 @@ title: Icons
Simple shortcode to include icons from SVG sprites outside of menus.
## Usage
<!-- prettier-ignore-start -->
```tpl
{{</* icon "thumbs-up" */>}}
```
<!-- prettier-ignore-end -->
## Usage
## Example
| Result | Usage |
| Output | Code |
| -------------------------- | -------------------------------- |
| {{< icon "thumbs-up" >}} | `{{</* icon "thumbs-up" */>}}` |
| {{< icon "thumbs-down" >}} | `{{</* icon "thumbs-down" */>}}` |

View File

@ -46,15 +46,6 @@ resources:
If you need more flexibility for your embedded images, you could use the `img` shortcode. It is using Hugo's
[page resources](https://gohugo.io/content-management/page-resources/) and supports lazy loading of your images.
## Attributes
| Name | Description | default |
| ---- | ------------------------------------------------------------ | ----------------- |
| name | name of the image resource defined in your front matter | empty |
| alt | description for displayed image | resource `.Title` |
| size | Thumbnail size (origin\|profile\|tiny\|small\|medium\|large) | empty |
| lazy | enable or disable image lazy loading | true |
## Usage
Define your resources in the page front matter, custom parameter `params.credits` is optional.
@ -74,6 +65,14 @@ resources:
{{</* img name="forest-1" size="large" lazy=false */>}}
```
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-images sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
<!-- spellchecker-enable -->
## Example

View File

@ -2,28 +2,27 @@
title: Includes
---
{{< toc >}}
Include shortcode can include files of different types. By specifying a language, the included file will have syntax highlighting.
## Usage
<!-- prettier-ignore-start -->
```tpl
{{</* include file="relative/path/from/hugo/root" language="go" */>}}
```
<!-- prettier-ignore-end -->
Attributes:
### Attributes
| Name | Description | Default |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
| file | path to the included file relative to the Hugo root | undefined |
| language | language for [syntax highlighting](https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages) | undefined |
| type | special include type (`html,page`) | undefined (rendered as markdown) |
| options | highlighting [options](https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode) | `linenos=table` |
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-includes sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Examples
## Example
### Markdown file (default)
### Example 1: Markdown file (default)
If no other options are specified, files will be rendered as Markdown using the `RenderString` [function](https://gohugo.io/functions/renderstring/).
@ -43,7 +42,7 @@ If you include markdown files that should not get a menu entry, place them outsi
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
### Language files
### Example 2: Language files
This method can be used to include source code files and keep them automatically up to date.
@ -60,9 +59,7 @@ Result:
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
### Special include types
#### HTML
### Example 3: HTML
HTML content will be filtered by the `safeHTML` filter and added to the rendered page output.
@ -73,9 +70,9 @@ HTML content will be filtered by the `safeHTML` filter and added to the rendered
{{< include file="/static/_includes/example.html.part" type="html" >}}
#### Pages
### Example 4: Hugo Pages
In some situations, it can be helpful to include Markdown files that also contain shortcodes. While the [default method](#markdown-file-default) works fine to render plain Markdown, shortcodes are not parsed. The only way to get this to work is to use Hugo pages. There are several ways to structure these include pages, so whatever you do, keep in mind that Hugo needs to be able to render and serve these files as regular pages! How it works:
In some situations, it can be helpful to include Markdown files that also contain shortcodes. While the [default method](#example-1-markdown-file-default) works fine to render plain Markdown, shortcodes are not parsed. The only way to get this to work is to use Hugo pages. There are several ways to structure these include pages, so whatever you do, keep in mind that Hugo needs to be able to render and serve these files as regular pages! How it works:
1. First you need to create a directory **within** your content directory. For this example site `_includes` is used.
2. To prevent the theme from embedding the page in the navigation, create a file `_includes/_index.md` and add `geekdocHidden: true` to the front matter.

View File

@ -4,7 +4,7 @@ title: KaTeX
[KaTeX](https://katex.org/) shortcode let you render math typesetting in markdown document.
## Example
## Usage
```latex
{{</* katex [display] [class="text-center"] */>}}
@ -12,6 +12,16 @@ f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
{{</* /katex */>}}
```
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-katex sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Example
<!-- spellchecker-disable -->
<!-- prettier-ignore -->
{{< katex display >}}
@ -20,4 +30,4 @@ f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
<!-- spellchecker-enable -->
KaTeX can be used inline, for example {{< katex >}}\pi(x){{< /katex >}} or used with the `display` parameter (see above).
KaTeX can be used inline, for example {{< katex >}}\pi(x){{< /katex >}} or used with the `display` parameter as above.

View File

@ -4,7 +4,7 @@ title: Mermaid
[Mermaid](https://mermaidjs.github.io/) is library for generating SVG charts and diagrams from text.
## Example
## Usage
<!-- prettier-ignore -->
```tpl
@ -22,6 +22,16 @@ sequenceDiagram
{{</* /mermaid */>}}
```
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-mermaid sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Example
<!-- spellchecker-disable -->
<!-- prettier-ignore -->
{{< mermaid class="text-center" >}}

View File

@ -4,20 +4,19 @@ title: Progress
A progress bar shows how far a process has progressed.
## Attributes
| Name | Description | default |
| ---------------- | -------------------------------------------------------------------------- | --------- |
| value | progress value | 0 |
| icon (optional) | icon to use, need to be an icon from an [SVG sprite](/features/icon-sets/) | undefined |
| title (optional) | progress title | undefined |
## Usage
<!-- prettier-ignore-start -->
<!-- prettier-ignore -->
```tpl
{{</* progress title=Eating value=65 icon=gdoc_heart */>}}
```
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-progress sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Example

View File

@ -4,14 +4,6 @@ title: Properties
The property list shortcode creates a custom HTML description list that can be used to display properties or variables and general dependent information. The shortcode requires a data file in `data/properties/`, e.g. `data/properties/demo.yaml`.
## Attributes
| Name | Description | default |
| ---------------- | ------------------------------------------------------ | --------- |
| name | name of the file from the `data/properties/` directory | undefined |
| sort (optional) | field name to use for sorting | undefined |
| order (optional) | sort order, only applied if `sort` is set | `asc` |
## Usage
<!-- prettier-ignore-start -->
@ -28,6 +20,14 @@ The supported attributes can be taken from the following example:
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-buttons sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Example
<!-- prettier-ignore-start -->

View File

@ -4,6 +4,8 @@ title: Tabs
Tabs let you organize content by context, for example installation instructions for each supported platform.
## Usage
<!-- prettier-ignore-start -->
```tpl
{{</* tabs "uniqueid" */>}}

View File

@ -4,6 +4,8 @@ title: ToC-Tree
The `toc-tree` shortcode will generate a Table of Content from a section file tree of your content directory. The root of the resulting ToC will be the page on which you define the shortcode.
## Usage
<!-- prettier-ignore-start -->
```tpl
{{</* toc-tree */>}}

View File

@ -4,21 +4,22 @@ title: ToC
Simple wrapper to generate a page Table of Content from a shortcode.
**Attributes:**
## Usage
| Name | Description | Default |
| ------ | -------------------------- | ------------------------------------------------------------- |
| format | format of the returned ToC | <!-- spellchecker-disable -->html<!-- spellchecker-enable --> |
**Usage:**
<!-- prettier-ignore-start -->
<!-- prettier-ignore -->
```tpl
{{</* toc (format=[html|raw]) */>}}
```
### Attributes
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=shortcode-toc sort=name order=asc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
**Example:**
## Example
{{< toc >}}

View File

@ -0,0 +1,19 @@
---
properties:
- name: href
type: string
description: The URL to use as target of the button.
required: false
- name: relref
type: string
description: Executes the [relref](https://gohugo.io/functions/urls/relref/) Hugo function to resolve the relative permalink of the specified page. The result is set as the target of the button.
required: false
- name: class
type: list
description: List of space-separated CSS class names to apply.
required: false
- name: size
type: string
description: Preset of different button sizes. Supported values are `regular|large`.
required: false
devaultValue: regular

View File

@ -0,0 +1,7 @@
---
properties:
- name: size
type: string
description: Preset of different sizes for the _first_ column. Supported values are `small|regular|large`.
required: false
defaultValue: regular

View File

@ -0,0 +1,15 @@
---
properties:
- name: type
type: string
description: Type of the hint. Supported values are `note|tip|important|caution|warning`.
required: false
defaultValue: note
- name: icon
type: string
description: Icon to use. The value need to be an icon from an [SVG sprite](/features/icon-sets/).
required: false
- name: title
type: string
description: Title text of the hint.
required: false

View File

@ -0,0 +1,19 @@
---
properties:
- name: name
type: string
description: Mame of the image resource defined in page front matter.
required: true
- name: alt
type: string
description: Description text for the image.
required: false
- name: size
type: string
description: Thumbnail size. Supported values are `origin|profile|tiny|small|medium|large`.
required: false
- name: lazy
type: bool
description: Enable/disable lazy loading for the image.
required: false
defaultValue: true

View File

@ -0,0 +1,19 @@
---
properties:
- name: file
type: string
description: Path of the file (relative to the Hugo root) to include.
required: true
- name: language
type: string
description: Language for [syntax highlighting](https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages).
required: false
- name: type
type: string
description: Special include type. Supported values are `html|page`. If not set the included file is rendered as markdown.
required: false
- name: options
type: bool
description: highlighting [options](https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode).
required: false
defaultValue: linenos=table

View File

@ -0,0 +1,6 @@
---
properties:
- name: class
type: list
description: List of space-separated CSS class names to apply.
required: false

View File

@ -0,0 +1,6 @@
---
properties:
- name: class
type: list
description: List of space-separated CSS class names to apply.
required: false

View File

@ -0,0 +1,15 @@
---
properties:
- name: value
type: integer
description: Progress value.
required: false
defaultValue: 0
- name: icon
type: string
description: Icon to use. The value need to be an icon from an [SVG sprite](/features/icon-sets/).
required: false
- name: title
type: string
description: Title text of the progress bar.
required: false

View File

@ -0,0 +1,15 @@
---
properties:
- name: name
type: string
description: Name of the file from the `data/properties/` directory.
required: true
- name: sort
type: string
description: Field name to use for sorting.
required: false
- name: order
type: string
description: Sort order, only applied if `sort` is set. Supported values are `asc|desc`.
required: false
defaultValue: asc

View File

@ -0,0 +1,10 @@
---
properties:
- name: format
type: string
description: |
Format of the returned ToC. The `html` format creates an HTML wrapper to enable the `geekdocToC` parameter that limits
the maximum ToC level to be displayed. This variant also automatically inserts a horizontal line after the ToC. The `raw` format
returns the unformatted ToC, the parameter `geekdocToC` does not work in this mode. Supported values are `html|raw`.
required: false
defaultValue: html