Skip to content
Snippets Groups Projects
Commit 4c64a068 authored by Lars Bilke's avatar Lars Bilke
Browse files

[web] Added bib-shortcode for inserting references.

Requires pandoc-citeproc tool.
parent 0a4aba9c
No related branches found
No related tags found
Loading
......@@ -52,6 +52,7 @@ find_program(NPM npm)
find_program(YARN yarn)
find_program(PIP pip)
find_package(PythonInterp)
find_program(PANDOC_CITEPROC pandoc-citeproc)
find_program(MODULE_CMD modulecmd
PATHS /usr/local/modules/3.2.10-1/Modules/3.2.10/bin)
......
......@@ -30,6 +30,13 @@ else()
message(STATUS "[web] Skipping import from Contentful!")
endif()
if(PANDOC_CITEPROC)
add_custom_target(web-bib-convert
COMMAND ${PANDOC_CITEPROC} --bib2json ${PROJECT_SOURCE_DIR}/Documentation/bibliography.bib > ${PROJECT_SOURCE_DIR}/web/data/bibliography.json
)
set(BIB_CONVERT_TARGET web-bib-convert)
endif()
if(DEFINED OGS_WEB_BASE_URL)
set(HUGO_ARGS --baseURL ${OGS_WEB_BASE_URL})
endif()
......@@ -41,7 +48,7 @@ endif()
add_custom_target(web
COMMAND ${NPM} run build:release -- ${HUGO_ARGS}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/web
DEPENDS web-install ${IMPORT_TARGET}
DEPENDS web-install ${IMPORT_TARGET} ${BIB_CONVERT_TARGET}
)
add_custom_target(web-clean
......
......@@ -12,5 +12,8 @@ yarn-error.log
# Generated from Contentful
content/internal
data/news.json
data/bibliography.json
import/c
# Generated by other tools
data/news.json
......@@ -131,6 +131,19 @@ Run `npm run convert` to get a list of possible arguments.
Equations can be set with typical LaTeX syntax by using [MathJax](https://www.mathjax.org/). Blocks are defined by `$$` at the beginning and `$$` at the end of the block. Inline math uses one `$` as the delimiter. For more usage instructions see the [MathJax LaTeX help](http://docs.mathjax.org/en/latest/tex.html).
### Bibliography references
Bibliography items from *Documentation/bibliography.bib* can be referenced by
their id with the `bib`-shortcode:
```go
{{< bib id="Kolditz2012" >}}
```
When building the `web`-target the file *Documentation/bibliography.bib* is
converted to *web/data/bibliography.json* with the tool `pandoc-citeproc`. This
json-file is then used by the shortcode.
## Developer notes
When adding a new module with `yarn add` you have to manually rebuild node-sass:
......
......@@ -33,4 +33,6 @@ $$
The relative error between the numerical simulation and the analytical solution is $9.2 \cdot 10^{-13}$.
Kolditz, Olaf, Uwe-Jens Görke, Hua Shao, and Wenqing Wang, eds. Thermo-hydro-mechanical-chemical processes in porous media: benchmarks and examples. Vol. 86. Springer Science & Business Media, 2012.
## References
{{< bib id="Kolditz2012" >}}
{{ if .Site.Data.bibliography }}
<p>
{{ $id := .Get "id" }}
{{ range where .Site.Data.bibliography "id" $id }}
{{ range .author }}
{{ .family }}, {{ .given}}
{{ end }}
({{ range .issued }}
{{ range . }}
{{ range . }}
{{.}}
{{ end }}
{{ end }}
{{ end }}):
<i>{{ .title }}</i>.
<!-- Workaround for keys with hyphens inside with index-function -->
{{ if isset . "container-title" }}{{ index . "container-title" }}{{ end }}
{{ if isset . "issue" }}{{ .issue }},{{ end }}
{{ if isset . "volume" }}vol. {{ .volume }},{{ end }}
{{ if isset . "page" }}p. {{ .page }},{{ end }}
{{ .publisher }}
{{ end }}
</p>
{{ else }}
{{ printf "Warning: Bibliography not converted! Missing bib id: "}}<code>{{.Get "id"}}</code>
{{ end }}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment