vscode
URI schemeVisual Studio Code can be launched with
a
vscode://
URI
like
any
of
the following:
vscode://file/full/path/to/directoy/
vscode://file/full/path/to/file
vscode://file/full/path/to/directoy/?windowId=_blank
vscode://file/full/path/to/file?windowId=_blank
ℹ |
|
Inspired by
the
March-2023
discourse.gohugo.io
discussion about
Open
content files via link in vscode from server-mode preview,
I created the following
layouts/partials/open-with/vscode.html
Hugo partial:
{{- with .File -}}
{{- $filepath := .Filename -}}
{{- $dirpath := print hugo.WorkingDir "/content/" .Dir -}}
{{- $sectionpath := print hugo.WorkingDir "/content/" .Section -}}
<pre>
<small>
<a href="vscode://file/{{- $filepath -}}?windowId=_blank">Edit File</a>
<a href="vscode://file/{{- $dirpath -}}?windowId=_blank">Edit Dir</a>
<a href="vscode://file/{{- $sectionpath -}}?windowId=_blank">Edit Section</a>
</small>
</pre>
{{- end -}} <!-- end with .File -->
💡 |
|
I call this partial near the top of my Hugo base template with the following Go template code.[3]
{{- if not hugo.IsProduction -}}
{{- partial "open-with/vscode" . -}}
{{- end -}}
discourse.gohugo.io/t/open-content-files-via-link-in-vscode-from-server-mode-preview/43669
gohugo.io/variables/files/
(discusses
.File.Filename
and
.File.Dir
)
gohugo.io/functions/hugo/
(discusses
hugo.IsProduction
and
hugo.WorkingDir
)
For more about Hugo, see Infinite Ink’s…
Hugo’s .RenderString
Method (featuring AsciiDoc admonitions in Go HTML and Markdown)
Hugo Shortcodes: How to Include Go Templates in Hugo Content Files
🔗 Linkified Section Headings in Hugo-Generated Web Pages (featuring Markdown and AsciiDoc examples)
Transforming Text with Hugo (featuring plainify
, htmlUnescape
, and more)
Hugo’s Markup Languages: AsciiDoc, HTML, Markdown,
TGIH: Themeless & Gitless Introduction to the Hugo SSG (a Hugo tutorial👩🏫)
Configuring Security in Hugo (featuring settings needed to use Asciidoctor and Pandoc)🔒
A Way to Compare Hugo’s Markup Languages (featuring inline footnotes)📊
Variable and Parameter Names in Hugo (featuring camelCase🐫 and snake_case🐍)
?windowId=_blank
to the vscode://
URI. To learn about this query parameter, see github.com/microsoft/vscode/issues/141548.@nm@mathstodon.xyz
or
#InfiniteInk
in it.