mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 23:38:53 +00:00
Use the new go-html-template Chroma lexer
This commit is contained in:
@@ -61,7 +61,7 @@ Note that changes to any resource inside the `content` folder will trigger a rel
|
||||
|
||||
#### List all Resources
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ range .Resources }}
|
||||
<li><a href="{{ .RelPermalink }}">{{ .ResourceType | title }}</a></li>
|
||||
{{ end }}
|
||||
@@ -73,7 +73,7 @@ For an absolute URL, use `.Permalink`.
|
||||
|
||||
#### List All Resources by Type
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ with .Resources.ByType "image" }}
|
||||
{{ end }}
|
||||
|
||||
@@ -83,7 +83,7 @@ Type here is `page` for pages, else the main type in the MIME type, so `image`,
|
||||
|
||||
#### Get a Specific Resource
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ $logo := .Resources.GetByPrefix "logo" }}
|
||||
{{ with $logo }}
|
||||
{{ end }}
|
||||
@@ -91,7 +91,7 @@ Type here is `page` for pages, else the main type in the MIME type, so `image`,
|
||||
|
||||
#### Include Page Resource Content
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ with .Resources.ByType "page" }}
|
||||
{{ range . }}
|
||||
<h3>{{ .Title }}</h3>
|
||||
@@ -146,7 +146,7 @@ This is the shortcode used in the examples above:
|
||||
|
||||
And it is used like this:
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{</* imgproc sunset Resize "300x" */>}}
|
||||
```
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ The `image` is a [Page Resource]({{< relref "content-management/page-resources"
|
||||
To get all images in a [Page Bundle]({{< relref "content-management/organization#page-bundles" >}}):
|
||||
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ with .Resources.ByType "image" }}
|
||||
{{ end }}
|
||||
|
||||
@@ -131,7 +131,7 @@ This is the shortcode used in the examples above:
|
||||
|
||||
And it is used like this:
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{</* imgproc sunset Resize "300x" /*/>}}
|
||||
```
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ anywhere:
|
||||
|
||||
But you can get it by `.Site.GetPage`. Here is an example:
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ $headless := .Site.GetPage "page" "some-headless-bundle" }}
|
||||
{{ $reusablePages := $headless.Resources.Match "author*" }}
|
||||
<h2>Authors</h2>
|
||||
|
||||
@@ -147,7 +147,7 @@ See [Highlight](/functions/highlight/).
|
||||
It is also possible to add syntax highlighting with GitHub flavored code fences. To enable this, set the `pygmentsCodeFences` to `true` in Hugo's [configuration file](/getting-started/configuration/);
|
||||
|
||||
````
|
||||
```html
|
||||
```go-html-template
|
||||
<section id="main">
|
||||
<div>
|
||||
<h1 id="title">{{ .Title }}</h1>
|
||||
|
||||
@@ -140,7 +140,7 @@ This is especially important for themes, but to list the most relevant pages on
|
||||
|
||||
This will, by default, list pages from the _section with the most pages_.
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
|
||||
```
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ categories: ["Releases"]
|
||||
|
||||
Hugo `0.27`comes with fast and flexible **Related Content** ([3b4f17bb](https://github.com/gohugoio/hugo/commit/3b4f17bbc9ff789faa581ac278ad109d1ac5b816) [@bep](https://github.com/bep) [#98](https://github.com/gohugoio/hugo/issues/98)). To add this to your site, put something like this in your single page template:
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ $related := .Site.RegularPages.Related . | first 5 }}
|
||||
{{ with $related }}
|
||||
<h3>See Also</h3>
|
||||
|
||||
@@ -11,7 +11,7 @@ images:
|
||||
|
||||
Hugo `0.27`comes with fast and flexible **Related Content** ([3b4f17bb](https://github.com/gohugoio/hugo/commit/3b4f17bbc9ff789faa581ac278ad109d1ac5b816) [@bep](https://github.com/bep) [#98](https://github.com/gohugoio/hugo/issues/98)). To add this to your site, put something like this in your single page template:
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ $related := .Site.RegularPages.Related . | first 5 }}
|
||||
{{ with $related }}
|
||||
<h3>See Also</h3>
|
||||
|
||||
@@ -184,7 +184,7 @@ outputs:
|
||||
|
||||
Each `Page` has both an `.OutputFormats` (all formats, including the current) and an `.AlternativeOutputFormats` variable, the latter of which is useful for creating a `link rel` list in your site's `<head>`:
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ range .AlternativeOutputFormats -}}
|
||||
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
|
||||
{{ end -}}
|
||||
@@ -194,7 +194,7 @@ Note that `.Permalink` and `.RelPermalink` on `Page` will return the first outpu
|
||||
|
||||
This is how you link to a given output format:
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
{{ with .OutputFormats.Get "json" -}}
|
||||
<a href="{{ .Permalink }}">{{ .Name }}</a>
|
||||
{{- end }}
|
||||
@@ -202,7 +202,7 @@ This is how you link to a given output format:
|
||||
|
||||
From content files, you can use the [`ref` or `relref` shortcodes](/content-management/shortcodes/#ref-and-relref):
|
||||
|
||||
```html
|
||||
```go-html-template
|
||||
[Neat]({{</* ref "blog/neat.md" "amp" */>}})
|
||||
[Who]({{</* relref "about.md#who" "amp" */>}})
|
||||
```
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
{{ $.Scratch.Set "codeLang" (index . 0 | strings.TrimPrefix ".") }}
|
||||
{{ end }}
|
||||
{{ with .Get "codeLang" }}{{ $.Scratch.Set "codeLang" . }}{{ end }}
|
||||
{{ if eq (.Scratch.Get "codeLang") "html"}}
|
||||
{{ $.Scratch.Set "codeLang" "go-html-template" }}
|
||||
{{ end }}
|
||||
<div class="code relative" id="{{ $file | urlize}}">
|
||||
{{- with $file -}}
|
||||
<div class="filename san-serif f6 dib lh-solid pl2 pv2">{{.}}</div>
|
||||
|
||||
Reference in New Issue
Block a user