mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 14:17:43 +00:00
Use the new go-html-template Chroma lexer
This commit is contained in:
9 files changed
+18
-15
No files matched your search
@@ -61,7 +61,7 @@ Note that changes to any resource inside the `content` folder will trigger a rel
|
|||||||
|
|
||||||
#### List all Resources
|
#### List all Resources
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{ range .Resources }}
|
{{ range .Resources }}
|
||||||
<li><a href="{{ .RelPermalink }}">{{ .ResourceType | title }}</a></li>
|
<li><a href="{{ .RelPermalink }}">{{ .ResourceType | title }}</a></li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@@ -73,7 +73,7 @@ For an absolute URL, use `.Permalink`.
|
|||||||
|
|
||||||
#### List All Resources by Type
|
#### List All Resources by Type
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{ with .Resources.ByType "image" }}
|
{{ with .Resources.ByType "image" }}
|
||||||
{{ end }}
|
{{ 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
|
#### Get a Specific Resource
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{ $logo := .Resources.GetByPrefix "logo" }}
|
{{ $logo := .Resources.GetByPrefix "logo" }}
|
||||||
{{ with $logo }}
|
{{ with $logo }}
|
||||||
{{ end }}
|
{{ 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
|
#### Include Page Resource Content
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{ with .Resources.ByType "page" }}
|
{{ with .Resources.ByType "page" }}
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
<h3>{{ .Title }}</h3>
|
<h3>{{ .Title }}</h3>
|
||||||
@@ -146,7 +146,7 @@ This is the shortcode used in the examples above:
|
|||||||
|
|
||||||
And it is used like this:
|
And it is used like this:
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{</* imgproc sunset Resize "300x" */>}}
|
{{</* 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" >}}):
|
To get all images in a [Page Bundle]({{< relref "content-management/organization#page-bundles" >}}):
|
||||||
|
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{ with .Resources.ByType "image" }}
|
{{ with .Resources.ByType "image" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ This is the shortcode used in the examples above:
|
|||||||
|
|
||||||
And it is used like this:
|
And it is used like this:
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{</* imgproc sunset Resize "300x" /*/>}}
|
{{</* imgproc sunset Resize "300x" /*/>}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ anywhere:
|
|||||||
|
|
||||||
But you can get it by `.Site.GetPage`. Here is an example:
|
But you can get it by `.Site.GetPage`. Here is an example:
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{ $headless := .Site.GetPage "page" "some-headless-bundle" }}
|
{{ $headless := .Site.GetPage "page" "some-headless-bundle" }}
|
||||||
{{ $reusablePages := $headless.Resources.Match "author*" }}
|
{{ $reusablePages := $headless.Resources.Match "author*" }}
|
||||||
<h2>Authors</h2>
|
<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/);
|
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">
|
<section id="main">
|
||||||
<div>
|
<div>
|
||||||
<h1 id="title">{{ .Title }}</h1>
|
<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_.
|
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 }}
|
{{ $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:
|
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 }}
|
{{ $related := .Site.RegularPages.Related . | first 5 }}
|
||||||
{{ with $related }}
|
{{ with $related }}
|
||||||
<h3>See Also</h3>
|
<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:
|
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 }}
|
{{ $related := .Site.RegularPages.Related . | first 5 }}
|
||||||
{{ with $related }}
|
{{ with $related }}
|
||||||
<h3>See Also</h3>
|
<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>`:
|
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 -}}
|
{{ range .AlternativeOutputFormats -}}
|
||||||
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
|
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
|
||||||
{{ end -}}
|
{{ 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:
|
This is how you link to a given output format:
|
||||||
|
|
||||||
```html
|
```go-html-template
|
||||||
{{ with .OutputFormats.Get "json" -}}
|
{{ with .OutputFormats.Get "json" -}}
|
||||||
<a href="{{ .Permalink }}">{{ .Name }}</a>
|
<a href="{{ .Permalink }}">{{ .Name }}</a>
|
||||||
{{- end }}
|
{{- 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):
|
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" */>}})
|
[Neat]({{</* ref "blog/neat.md" "amp" */>}})
|
||||||
[Who]({{</* relref "about.md#who" "amp" */>}})
|
[Who]({{</* relref "about.md#who" "amp" */>}})
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
{{ $.Scratch.Set "codeLang" (index . 0 | strings.TrimPrefix ".") }}
|
{{ $.Scratch.Set "codeLang" (index . 0 | strings.TrimPrefix ".") }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ with .Get "codeLang" }}{{ $.Scratch.Set "codeLang" . }}{{ 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}}">
|
<div class="code relative" id="{{ $file | urlize}}">
|
||||||
{{- with $file -}}
|
{{- with $file -}}
|
||||||
<div class="filename san-serif f6 dib lh-solid pl2 pv2">{{.}}</div>
|
<div class="filename san-serif f6 dib lh-solid pl2 pv2">{{.}}</div>
|
||||||
|
|||||||
Reference in new issue
Block a user