feat: enable adding URL/path to code blocks (#307)

This commit is contained in:
welpo
2024-05-03 17:37:40 +02:00
parent 0cbd727f25
commit b70efd1642
17 changed files with 175 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
+++
title = "Shortcodes personalitzats"
date = 2023-02-19
updated = 2024-05-02
updated = 2024-05-03
description = "Aquest tema inclou alguns shortcodes personalitzats útils que pots utilitzar per millorar les teves publicacions. Ja sigui per mostrar imatges que s'adapten als temes clar i fosc, o per donar format a una secció de referències amb un aspecte professional, aquests shortcodes personalitzats t'ajudaran."
[taxonomies]
@@ -11,6 +11,7 @@ tags = ["funcionalitat", "shortcodes"]
toc = true
toc_levels = 2
quick_navigation_buttons = true
add_src_to_code_block = true
social_media_card = "social_cards/ca_blog_shortcodes.jpg"
+++
@@ -95,6 +96,33 @@ Tots els altres shortcodes d'imatges poden utilizar l'amplada completa assignant
{{/* full_width_image(src="img/amsterdam_by_oskerwyld.webp", alt="Fotografia d'un canal a Àmsterdam") */}}
```
## Shortcodes de codi
### Mostrar ruta o URL
Mostra una ruta o URL al següent bloc de codi trobat. Si comença amb "http", es convertirà en un enllaç. Particularment útil quan s'utilitza en conjunció amb el [shortcode de text remot](#text-remot).
{{ admonition(type="warning", title="IMPORTANT", text="Aquesta funcionalitat requereix JavaScript. Per activar-la, configura `add_src_to_code_block = true` a la secció `[extra]` de la teva pàgina, secció, o `config.toml`.") }}
{{ add_src_to_code_block(src="https://github.com/welpo/doteki/blob/main/.gitignore") }}
```.gitignore
{{ remote_text(src="https://raw.githubusercontent.com/welpo/doteki/main/.gitignore") }}
```
#### Ús
````
{{/* add_src_to_code_block(src="https://github.com/welpo/doteki/blob/main/.gitignore") */}}
```.gitignore
__pycache__/
*coverage*
.vscode/
dist/
```
````
## Shortcodes de text
### Text remot

View File

@@ -1,7 +1,7 @@
+++
title = "Shortcodes personalizados"
date = 2023-02-19
updated = 2024-05-02
updated = 2024-05-03
description = "Este tema incluye algunos shortcodes personalizados útiles que puedes utilizar para mejorar tus publicaciones. Puedes mostrar imágenes que se adapten a los temas claro y oscuro, dar formato a una sección de referencias con un aspecto profesional, y más."
[taxonomies]
@@ -11,6 +11,7 @@ tags = ["funcionalidad", "shortcodes"]
toc = true
toc_levels = 2
quick_navigation_buttons = true
add_src_to_code_block = true
social_media_card = "social_cards/es_blog_shortcodes.jpg"
+++
@@ -96,6 +97,33 @@ Todos los otros shortcodes de imágenes pueden usar el ancho completo asignando
{{/* full_width_image(src="img/amsterdam_by_oskerwyld.webp", alt="Fotografía de un canal en Ámsterdam") */}}
```
## Shortcodes de código
### Mostrar ruta o URL
Muestra una ruta o URL en el siguiente bloque de código encontrado. Si comienza con "http", se convertirá en un enlace. Particularmente útil cuando se usa junto con el [shortcode de texto remot](#texto-remoto).
{{ add_src_to_code_block(src="https://github.com/welpo/doteki/blob/main/.gitignore") }}
```.gitignore
{{ remote_text(src="https://raw.githubusercontent.com/welpo/doteki/main/.gitignore") }}
```
{{ admonition(type="warning", title="IMPORTANT", text="Esta característica requiere JavaScript. Para habilitarla, configura `add_src_to_code_block = true` en la sección `[extra]` de tu página, sección, o `config.toml`.") }}
#### Uso
````
{{/* add_src_to_code_block(src="https://github.com/welpo/doteki/blob/main/.gitignore") */}}
```.gitignore
__pycache__/
*coverage*
.vscode/
dist/
```
````
## Shortcodes de texto
### Texto remoto

View File

@@ -1,7 +1,7 @@
+++
title = "Custom shortcodes"
date = 2023-02-19
updated = 2024-05-02
updated = 2024-05-03
description = "This theme includes some useful custom shortcodes that you can use to enhance your posts. Whether you want to display images that adapt to light and dark themes, or format a professional-looking reference section, these custom shortcodes have got you covered."
[taxonomies]
@@ -11,6 +11,7 @@ tags = ["showcase", "shortcodes"]
toc = true
toc_levels = 2
quick_navigation_buttons = true
add_src_to_code_block = true
social_media_card = "social_cards/blog_shortcodes.jpg"
+++
@@ -95,11 +96,38 @@ All other image shortcodes can be made into full-width by setting the optional p
{{/* full_width_image(src="img/amsterdam_by_oskerwyld.webp", alt="Photograph of a canal in Amsterdam") */}}
```
## Code shortcodes
### Show source or path
Display a path or URL on the next code block found. If it starts with "http", it will become a link. Particularly useful when used in conjunction with the [remote text shortcode](#remote-text).
{{ add_src_to_code_block(src="https://github.com/welpo/doteki/blob/main/.gitignore") }}
```.gitignore
{{ remote_text(src="https://raw.githubusercontent.com/welpo/doteki/main/.gitignore") }}
```
{{ admonition(type="warning", title="IMPORTANT", text="This feature requires JavaScript. To enable it, set `add_src_to_code_block = true` on the `[extra]` section of your page, section, or `config.toml`.") }}
#### Usage
````
{{/* add_src_to_code_block(src="https://github.com/welpo/doteki/blob/main/.gitignore") */}}
```.gitignore
__pycache__/
*coverage*
.vscode/
dist/
```
````
## Text shortcodes
### Remote text
Embed text from a remote URL or a local file.
Embed text from a remote URL or a local file. To display the path or URL on the code block, see the [show source or path shortcode](#show-source-or-path).
**Important**: