Skip to content

Commit

Permalink
docs: use a propertylist to document shortcode attributes (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys committed Oct 27, 2023
1 parent 76ef8f1 commit 83469c4
Show file tree
Hide file tree
Showing 24 changed files with 254 additions and 92 deletions.
11 changes: 10 additions & 1 deletion exampleSite/content/en/shortcodes/buttons.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions exampleSite/content/en/shortcodes/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
32 changes: 15 additions & 17 deletions exampleSite/content/en/shortcodes/expand.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

### Default
## Usage

<!-- prettier-ignore-start -->
```tpl
{{</* expand */>}}
## Markdown content
### Markdown content
Dolor sit, sumo unique ...
{{</* /expand */>}}
```
<!-- prettier-ignore-end -->

{{< expand >}}

## 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
It is also possible to use a custom label and symbol.

<!-- prettier-ignore-start -->

```tpl
{{</* expand "Custom Label" "..." */>}}
## Markdown content
### More markdown
Dolor sit, sumo unique ...
{{</* /expand */>}}
```
<!-- prettier-ignore-end -->

## Example

{{< expand >}}

### 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 >}}

{{< 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
Expand Down
16 changes: 8 additions & 8 deletions exampleSite/content/en/shortcodes/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand All @@ -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 >}}
Expand Down
6 changes: 4 additions & 2 deletions exampleSite/content/en/shortcodes/icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" */>}}` |
Expand Down
17 changes: 8 additions & 9 deletions exampleSite/content/en/shortcodes/images/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
31 changes: 14 additions & 17 deletions exampleSite/content/en/shortcodes/includes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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.
Expand Down
14 changes: 12 additions & 2 deletions exampleSite/content/en/shortcodes/katex.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ title: KaTeX

[KaTeX](https://katex.org/) shortcode let you render math typesetting in markdown document.

## Example
## Usage

```latex
{{</* katex [display] [class="text-center"] */>}}
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 >}}
Expand All @@ -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.
12 changes: 11 additions & 1 deletion exampleSite/content/en/shortcodes/mermaid.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" >}}
Expand Down
17 changes: 8 additions & 9 deletions exampleSite/content/en/shortcodes/progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions exampleSite/content/en/shortcodes/propertylist.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand All @@ -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 -->
Expand Down

0 comments on commit 83469c4

Please sign in to comment.