Update all uses of readfile SC to use root path

This commit is contained in:
Ryan Watters
2017-03-25 14:19:15 -05:00
parent 025011295b
commit a479cb136b
7 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -460,7 +460,7 @@ Apache License - 60
## Current Content (Source)
```markdown
{{< readfile file="content/tree.txt" >}}
{{< readfile file="/content/tree.txt" >}}
```
## Ideal Workflow
+1 -1
View File
@@ -175,7 +175,7 @@ As an example of archetypes in practice, the following is the `functions` archet
{{% code file="archetypes/functions.md" %}}
```yaml
{{< readfile file="archetypes/functions.md" >}}
{{< readfile file="/archetypes/functions.md" >}}
```
{{% /code %}}
+1 -1
View File
@@ -25,7 +25,7 @@ Before you begin writing your content in markdown, Blackfriday has a known issue
You can configure multiple aspects of Blackfriday as show in the following list. See the docs on [Configuration][config] for the full list of explicit directions you can give to Hugo when rendering your site.
{{< readfile file="content/readfiles/bfconfig.md" markdown="true" >}}
{{< readfile file="/content/readfiles/bfconfig.md" markdown="true" >}}
## Extending Markdown
+3 -3
View File
@@ -51,7 +51,7 @@ The archetype for the `functions` content type is as follows:
{{% code file="archetypes/functions.md" %}}
```yaml
{{< readfile file="archetypes/functions.md">}}
{{< readfile file="/archetypes/functions.md">}}
```
{{% /code %}}
@@ -103,7 +103,7 @@ The archetype for the `showcase` content type is as follows:
{{% code file="archetypes/showcase.md" %}}
```yaml
{{< readfile file="archetypes/showcase.md">}}
{{< readfile file="/archetypes/showcase.md">}}
```
{{% /code %}}
@@ -143,7 +143,7 @@ The archetype for the `tutorials` content type is as follows:
{{% code file="archetypes/tutorials.md" %}}
```yaml
{{< readfile file="archetypes/tutorials.md">}}
{{< readfile file="/archetypes/tutorials.md">}}
```
{{% /code %}}
+1 -1
View File
@@ -344,7 +344,7 @@ Hugo typically configures Blackfriday with sane default values that should fit m
However, if you have specific needs with respect to Markdown, Hugo exposes some of its Blackfriday behavior options for you to alter. The following table lists these Hugo options, paired with the corresponding flags from Blackfriday's source code ( [html.go](https://github.com/russross/blackfriday/blob/master/html.go) and [markdown.go](https://github.com/russross/blackfriday/blob/master/markdown.go)).
{{< readfile file="content/readfiles/bfconfig.md" markdown="true" >}}
{{< readfile file="/content/readfiles/bfconfig.md" markdown="true" >}}
{{% note %}}
1. Blackfriday flags are *case sensitive* as of Hugo v0.15.
+1 -1
View File
@@ -10,7 +10,7 @@ These files are called using the [`readfile` shortcode (source)](../layouts/read
You can call this shortcode in the docs as follows:
<code>{</code><code>{</code>% readfile file="path/to/file.txt" markdown="true" %<code>}</code><code>}</code>
<code>{</code><code>{</code>% readfile file="/path/to/file.txt" markdown="true" %<code>}</code><code>}</code>
`markdown="true"` is optional (default = `"false"`) and parses the string through the Blackfriday renderer.
+8 -8
View File
@@ -33,7 +33,7 @@ This shortcode creates a link to each of the files in a directory---display as t
{{% code file="layouts/shortcodes/directoryindex.html" download="directoryindex.html" %}}
```html
{{< readfile file="layouts/shortcodes/directoryindex.html" >}}
{{< readfile file="/layouts/shortcodes/directoryindex.html" >}}
```
{{% /code %}}
@@ -60,7 +60,7 @@ The [`readfile` function][reads] reads a file from disk and converts it into a s
To use the `readFile` function in your templates, make sure the path is relative to your *Hugo project's root directory*:
```html
{{ readFile "content/templates/local-file-templates" }}
{{ readFile "/content/templates/local-file-templates" }}
```
### `readFile` Example: Add a Project File to Content
@@ -68,38 +68,38 @@ To use the `readFile` function in your templates, make sure the path is relative
As `readFile` is a function, it is only available to you in your templates and not your content. However, we can create a simple [shortcode template][sct] that calls `readFile`, passes the first argument through the function, and then allows an optional second argument to send the file through the Blackfriday markdown processor. The pattern for adding this shortcode to your content will be as follows:
```
{{</* readfile file="path/to/local/file.txt" markdown="true" */>}}
{{</* readfile file="/path/to/local/file.txt" markdown="true" */>}}
```
Here is the templating for our new `readfile` shortcode:
{{% code file="layouts/shortcodes/readfile.html" download="readfile.html" %}}
```
{{< readfile file="layouts/shortcodes/readfile.html">}}
{{< readfile file="/layouts/shortcodes/readfile.html">}}
```
{{% /code %}}
This `readfile` shortcode is [also part of the Hugo docs][readfilesource]. So is [`testing.txt`][testfile], which we will call in this example by passing it into our new `readfile` shortcode as follows:
```
{{</* readfile file="content/readfiles/testing.txt" */>}}
{{</* readfile file="/content/readfiles/testing.txt" */>}}
```
The output "string" for this shortcode declaration will be the following:
```markdown
{{< readfile file="content/readfiles/testing.txt" >}}
{{< readfile file="/content/readfiles/testing.txt" >}}
```
However, if we want Hugo to pass this string through Blackfriday, we should add the `markdown="true"` optional parameter:
```html
{{</* readfile file="content/readfiles/testing.txt" markdown="true" */>}}
{{</* readfile file="/content/readfiles/testing.txt" markdown="true" */>}}
```
And here is the result as [called directly in the Hugo docs][] and rendered for display:
{{< readfile file="content/readfiles/testing.txt" markdown="true">}}
{{< readfile file="/content/readfiles/testing.txt" markdown="true">}}
[called directly in the Hugo docs]: https://github.com/spf13/hugo/blob/master/docs/content/templates/files.md
[dirindex]: https://github.com/spf13/hugo/blob/master/docs/layouts/shortcodes/directoryindex.html