fix: remove relURL from markdown render image hook (#93)
* fix: remove relURL from markdown render image hook BREAKING CHANGE: As the relURL function in markdown render hooks caused some unwanted side effects we had to remove it. Related to this change the behavior for sites deployed to a subdirectory has changed as well! Please check the [documentation](https://geekdocs.de/usage/getting-started/#sub-directories) how to workaround subdirectory deployments. * restructure color-schemes page to work as image bundle example * fix wording
This commit is contained in:
parent
1ace505d27
commit
a8de42c489
7 changed files with 96 additions and 6 deletions
|
@ -16,3 +16,7 @@ IcoMoon
|
|||
YAML
|
||||
ok
|
||||
FontAwesome
|
||||
Netlify
|
||||
Makefile
|
||||
prebuilt
|
||||
(S|s)ubdirector(ies|y)
|
||||
|
|
|
@ -2,10 +2,9 @@ If you want to customize the color scheme of the theme to give it your individua
|
|||
|
||||
All necessary class names are listed below. If you miss some classes required for a color scheme you are very welcome to create an [Issue](https://github.com/thegeeklab/hugo-geekdoc/issues) or Pull Request. For some inspiration you can have a look at [https://www.color-hex.com/color-palettes/](https://www.color-hex.com/). The following listing use the _HC-primary_ color palette as an example:
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
<!-- markdownlint-disable -->
|
||||
<!-- spellchecker-disable -->
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
{{< highlight CSS "linenos=table" >}}
|
||||
/* default link color */
|
||||
a { color: #1c388e; }
|
||||
|
@ -34,11 +33,10 @@ a:visited { color: #73bfb8 }
|
|||
.gdoc-hint.warning { background: #fef5dc; border-color: #e4ba48; color: black; }
|
||||
.gdoc-hint.danger { background: #fae1db; border-color: #cf5f46; color: black; }
|
||||
{{< /highlight >}}
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
<!-- spellchecker-enable -->
|
||||
<!-- markdownlint-enable -->
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
And that is how the result will looks like. Happy customizing!
|
||||
|
||||
[![HC-primary Color Scheme](/media/colorscheme-example.png)](/media/colorscheme-example.png)
|
||||
[![HC-primary Color Scheme](images/colorscheme-example.png)](images/colorscheme-example.png)
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 159 KiB |
|
@ -85,6 +85,11 @@ enableGitInfo = true
|
|||
# (Optional, default true) Enable or disable image lazy loading for images rendered
|
||||
# by the 'img' shortcode.
|
||||
geekdocImageLazyLoading = true
|
||||
|
||||
# (Optional, default false) Set HTMl <base> to .Site.BaseURL if enabled. Is might be required
|
||||
# a subdirectory is used within Hugos BaseURL.
|
||||
# See https://developer.mozilla.org/de/docs/Web/HTML/Element/base.
|
||||
geekdocOverwriteHTMLBase = false
|
||||
```
|
||||
|
||||
{{< /tab >}}
|
||||
|
@ -168,6 +173,11 @@ params:
|
|||
# (Optional, default true) Enable or disable image lazy loading for images rendered
|
||||
# by the 'img' shortcode.
|
||||
geekdocImageLazyLoading: true
|
||||
|
||||
# (Optional, default false) Set HTMl <base> to .Site.BaseURL if enabled. Is might be required
|
||||
# a subdirectory is used within Hugos BaseURL.
|
||||
# See https://developer.mozilla.org/de/docs/Web/HTML/Element/base.
|
||||
geekdocOverwriteHTMLBase: false
|
||||
```
|
||||
|
||||
{{< /tab >}}
|
||||
|
|
|
@ -98,3 +98,77 @@ Build required theme assets e.g. CSS files and SVG sprites with `gulp`.
|
|||
```Shell
|
||||
npx gulp default
|
||||
```
|
||||
|
||||
## Deployments
|
||||
|
||||
### Netlify
|
||||
|
||||
There are several ways to deploy your site with this theme on Netlify. Regardless of which solution you choose, the main goal is to ensure that the prebuilt theme release tarball is used or to run the [required commands](#option-2-clone-the-github-repository) to prepare the theme assets before running the Hugo build command.
|
||||
|
||||
Here are some possible solutions:
|
||||
|
||||
**Use a Makefile:**
|
||||
|
||||
Add a Makefile to your repository to bundle the required steps.
|
||||
|
||||
```Makefile
|
||||
THEME_VERSION := v0.8.2
|
||||
THEME := hugo-geekdoc
|
||||
BASEDIR := docs
|
||||
THEMEDIR := $(BASEDIR)/themes
|
||||
|
||||
.PHONY: doc
|
||||
doc: doc-assets doc-build
|
||||
|
||||
.PHONY: doc-assets
|
||||
doc-assets:
|
||||
mkdir -p $(THEMEDIR)/$(THEME)/ ; \
|
||||
curl -sSL "https://github.com/thegeeklab/$(THEME)/releases/download/${THEME_VERSION}/$(THEME).tar.gz" | tar -xz -C $(THEMEDIR)/$(THEME)/ --strip-components=1
|
||||
|
||||
.PHONY: doc-build
|
||||
doc-build:
|
||||
cd $(BASEDIR); hugo
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(THEMEDIR) && \
|
||||
rm -rf $(BASEDIR)/public
|
||||
```
|
||||
|
||||
This Makefile can be used in your `netlify.toml`, take a look at the Netlify [example](https://docs.netlify.com/configure-builds/file-based-configuration/#sample-file) for more information:
|
||||
|
||||
```toml
|
||||
[build]
|
||||
publish = "docs/public"
|
||||
command = "make doc"
|
||||
```
|
||||
|
||||
**Chain required commands:**
|
||||
|
||||
Chain all required commands to prepare the theme and build your site on the `command` option in your `netlify.toml` like this:
|
||||
|
||||
```toml
|
||||
[build]
|
||||
publish = "docs/public"
|
||||
command = "command1 && command 2 && command3 && hugo"
|
||||
```
|
||||
|
||||
### Subdirectories
|
||||
|
||||
{{< hint danger >}}
|
||||
**Warning**\
|
||||
As deploying Hugo sites on subdirectories is not as robust as on subdomains, we do not recommend this.
|
||||
If you have a choice, using a domain/subdomain should always be the preferred solution!
|
||||
{{< /hint >}}
|
||||
|
||||
If you want to deploy your side to a subdirectory of your domain, some extra steps are required:
|
||||
|
||||
- Configure your Hugo base URL e.g. `baseURL = http://localhost/demo/`.
|
||||
- Don't use `relativeURLs: false` nor `canonifyURLs: true` as is can cause unwanted side effects!
|
||||
|
||||
There are two ways to get Markdown links or images working:
|
||||
|
||||
- Use the absolute path including your subdirectory e.g. `[testlink](/demo/example-site)`
|
||||
- Overwrite the HTML base in your site configuration with `geekdocOverwriteHTMLBase = true` and use the relative path e.g. `[testlink](example-site)`
|
||||
|
||||
But there is another special case if you use `geekdocOverwriteHTMLBase = true`. If you use anchors in your Markdown links you have to ensure to always include the page path. As an example `[testlink](#some-anchor)` will resolve to `http://localhost/demo/#some-anchor` and not automatically include the current page!
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<img src="{{ .Destination | safeURL | relURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
|
||||
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
|
||||
{{- /* Drop trailing newlines */ -}}
|
||||
|
|
|
@ -31,4 +31,8 @@
|
|||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
||||
{{ end -}}
|
||||
|
||||
{{ if (default false $.Site.Params.GeekdocOverwriteHTMLBase) }}
|
||||
<base href="{{ .Site.BaseURL }}">
|
||||
{{ end }}
|
||||
|
||||
{{ printf "<!-- %s -->" "Made with Geekdoc theme https://github.com/thegeeklab/hugo-geekdoc" | safeHTML }}
|
||||
|
|
Loading…
Reference in a new issue