Help:Shortcode Reporef
Create a string, which can be used as link to the repo for a local path.
On this page
On this page
Shortcode | |
Description | |
---|---|
Type | HTML Shortcode |
Nested? | false |
Shortcode | reporef |
Return Type | HTML |
Short Description Create a string, which can be used as link to the repo for a local path | |
Development | |
Maintainer | Michael Sasser |
This shortcode works exactly like the ref
shortcode, but the resulting link
points to the repo instead.
For more information on the ref
shortcode, check out the shortcodes docs.
Parameters
The details shortcode has the following parameters:
Parameter | Description |
---|---|
[0] | The path to a page, with or without a file extension, with or without an anchor. A path without a leading / is first resolved relative to the given context, then to the remainder of the site. |
Examples
{{< reporef "wiki/Help:Shortcode_Ln" >}}
Rendered
https://gitlab.com/matrixpython/website/-/blob/main/content/en/wiki/Help:Shortcode_Ln
Code
Below you find the implementation of the shortcode.
HTML
Defined in layouts/shortcodes/reporef.html
.
This code is licensed under the MIT license.
<!--
Reporef Shortcode
=================
Contributors: Michael Sasser
Maintainer: Michael Sasser
License: MIT
Version: 1
Child Shortcodes: None
Parent Shortcodes: None
LAYOUT: /layouts/shortcodes/reporef.md
DOCS: /content/<language>/wiki/Help:Shortcode_Reporef.md
Description
-----------
Create a string for a link to the websites repository.
Changelog
=========
Version 1 (2022-07-22)
----------------------
Initial release
-->
{{- $path := (index .Params 0) -}}
{{- $parts := slice .Site.Params.docsRepo -}}
{{- if (eq .Site.Params.repoHost "GitHub") -}}
{{- $parts = $parts | append "blob" .Site.Params.docsRepoBranch -}}
{{- else if (eq .Site.Params.repoHost "Gitea") -}}
{{- $parts = $parts | append "_edit" .Site.Params.docsRepoBranch -}}
{{- else if (eq .Site.Params.repoHost "GitLab") -}}
{{- $parts = $parts | append "-/blob" .Site.Params.docsRepoBranch -}}
{{- else if (eq .Site.Params.repoHost "Bitbucket") -}}
{{- $parts = $parts | append "src" .Site.Params.docsRepoBranch -}}
{{- else if (eq .Site.Params.repoHost "BitbucketServer") -}}
{{- $parts = $parts | append "browse" .Site.Params.docsRepoBranch -}}
{{- end -}}
{{- if isset .Site.Params "docsreposubpath" -}}
{{- if not (eq .Site.Params.docsRepoSubPath "") -}}
{{- $parts = $parts | append .Site.Params.docsRepoSubPath -}}
{{- end -}}
{{- end -}}
{{- $parts = $parts | append "content" .Page.Lang $path -}}
{{- $url := delimit $parts "/" -}}
{{ $url := replace $url "//" "/" }}
{{ $url := replace $url "https:/" "https://" }}
{{- $url | markdownify -}}
Download
Copy the source code above or use the download link below to use this file on your website according to the license.
- reporef.html ❘ 1.60 KB
- md5 cab9230d422a4bbf6289cfd48e344305
- sha1 c821a9f1d359bcbcafb3d16f1098e271b3c4da79
- sha256 81eaa1b97d48713daa1995f45310c0386f19978ab89456a6d9c1cbc42e569c35
Categories | Contributors |
---|---|
Help, Contribute and Shortcode | Michael Sasser |