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

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