Skip to content

Commit 858b5b1

Browse files
authored
update markdown blog post (#190)
1 parent 49f9325 commit 858b5b1

File tree

2 files changed

+228
-65
lines changed

2 files changed

+228
-65
lines changed

docs/blog/posts/2022/blog-launch.md

Lines changed: 205 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ This blog post explains how to contribute a blog article to our portal and what
1616

1717
<!-- more -->
1818

19-
!!!question "What should I write about? Or should I even start writing?"
20-
Likely the hardest thing in writing is to start. You may have dozens of doubts preventing you start writing.
19+
/// admonition | What should I write about? Or should I even start writing?
20+
type: question
21+
Likely the hardest thing in writing is to start. You may have dozens of doubts preventing you start writing.
2122

22-
*Is this interesting to anyone? Isn't it too obvious? Is it too short/long?*
23+
*Is this interesting to anyone? Isn't it too obvious? Is it too short/long?*
2324

24-
The best advice here might be just to start writing and reiterate as you go. Nothing is perfect, and we welcome all to embrace the joy of writing, which helps to structure your own thoughts and get a firmer grip on the topic.
25+
The best advice here might be just to start writing and reiterate as you go. Nothing is perfect, and we welcome all to embrace the joy of writing, which helps to structure your own thoughts and get a firmer grip on the topic.
2526

26-
SR Linux appreciates modern network architectures, network automation/orchestration and programmability. Anything that falls under and in-between these domains will make a great blog post.
27+
SR Linux appreciates modern network architectures, network automation/orchestration and programmability. Anything that falls under and in-between these domains will make a great blog post.
28+
///
2729

2830
## Creating a blog post
2931

@@ -58,61 +60,69 @@ This portal uses the famous [mkdocs-material](https://squidfunk.github.io/mkdocs
5860

5961
We would like to highlight a few UI elements we use all the time and hope you'll also like them.
6062

61-
!!!tip
62-
Check the [mkdocs-material reference](https://squidfunk.github.io/mkdocs-material/reference/) for a deep dive in the ocean of options and elements mkdocs-material theme provides.
63+
/// admonition
64+
type: tip
65+
Check the [mkdocs-material reference](https://squidfunk.github.io/mkdocs-material/reference/) for a deep dive in the ocean of options and elements mkdocs-material theme provides.
66+
///
6367

6468
### Tabs
6569

6670
Tabs help to visually organize the content and improve readability an awful lot.
6771

68-
``` title="Content tabs with code blocks"
69-
=== "C"
72+
```` title="Content tabs with code blocks"
73+
/// tab | C
7074
71-
``` c
72-
#include <stdio.h>
75+
``` c
76+
#include <stdio.h>
7377
74-
int main(void) {
75-
printf("Hello world!\n");
76-
return 0;
77-
}
78-
```
78+
int main(void) {
79+
printf("Hello world!\n");
80+
return 0;
81+
}
82+
```
7983
80-
=== "C++"
84+
///
85+
/// tab | C++
8186
82-
``` c++
83-
#include <iostream>
87+
``` c++
88+
#include <iostream>
8489
85-
int main(void) {
86-
std::cout << "Hello world!" << std::endl;
87-
return 0;
88-
}
89-
```
90+
int main(void) {
91+
std::cout << "Hello world!" << std::endl;
92+
return 0;
93+
}
9094
```
9195
96+
///
97+
98+
````
99+
92100
<div class="result" markdown>
93101

94-
=== "C"
102+
/// tab | C
95103

96-
``` c
97-
#include <stdio.h>
104+
``` c
105+
#include <stdio.h>
98106

99-
int main(void) {
100-
printf("Hello world!\n");
101-
return 0;
102-
}
103-
```
107+
int main(void) {
108+
printf("Hello world!\n");
109+
return 0;
110+
}
111+
```
104112
105-
=== "C++"
113+
///
114+
/// tab | C++
106115
107-
``` c++
108-
#include <iostream>
116+
``` c++
117+
#include <iostream>
109118
110-
int main(void) {
111-
std::cout << "Hello world!" << std::endl;
112-
return 0;
113-
}
114-
```
119+
int main(void) {
120+
std::cout << "Hello world!" << std::endl;
121+
return 0;
122+
}
123+
```
115124

125+
///
116126
</div>
117127

118128
### Code
@@ -122,14 +132,15 @@ Nowadays, code is everywhere. With a few styling aids you can make your code blo
122132
A regular code block with a syntax highlighting uses code fences style:
123133

124134
```` markdown title="Code block"
125-
``` py
135+
```py
126136
import tensorflow as tf
127137
```
138+
128139
````
129140

130141
<div class="result" markdown>
131142

132-
``` py
143+
```py
133144
import tensorflow as tf
134145
```
135146

@@ -139,8 +150,8 @@ import tensorflow as tf
139150

140151
To add a title to a code block, use the `title` attribute:
141152

142-
```` markdown title="Code block with title"
143-
``` py title="bubble_sort.py"
153+
````markdown title="Code block with title"
154+
```py title="bubble_sort.py"
144155
def bubble_sort(items):
145156
for i in range(len(items)):
146157
for j in range(len(items) - 1 - i):
@@ -151,7 +162,7 @@ def bubble_sort(items):
151162

152163
<div class="result" markdown>
153164

154-
``` py title="bubble_sort.py"
165+
```py title="bubble_sort.py"
155166
def bubble_sort(items):
156167
for i in range(len(items)):
157168
for j in range(len(items) - 1 - i):
@@ -168,8 +179,8 @@ option directly after the shortcode, whereas `<start>` represents the starting
168179
line number. A code block can start from a line number other than `1`, which
169180
allows to split large code blocks for readability:
170181

171-
```` markdown title="Code block with line numbers"
172-
``` py linenums="1"
182+
````markdown title="Code block with line numbers"
183+
```py linenums="1"
173184
def bubble_sort(items):
174185
for i in range(len(items)):
175186
for j in range(len(items) - 1 - i):
@@ -180,7 +191,7 @@ def bubble_sort(items):
180191

181192
<div class="result" markdown>
182193

183-
``` py linenums="1"
194+
```py linenums="1"
184195
def bubble_sort(items):
185196
for i in range(len(items)):
186197
for j in range(len(items) - 1 - i):
@@ -196,8 +207,8 @@ Specific lines can be highlighted by passing the line numbers to the `hl_lines`
196207
argument placed right after the language shortcode. Note that line counts start
197208
at `1`, regardless of the starting line number specified:
198209

199-
```` markdown title="Code block with highlighted lines"
200-
``` py hl_lines="2 3"
210+
````markdown title="Code block with highlighted lines"
211+
```py hl_lines="2 3"
201212
def bubble_sort(items):
202213
for i in range(len(items)):
203214
for j in range(len(items) - 1 - i):
@@ -208,7 +219,7 @@ def bubble_sort(items):
208219

209220
<div class="result" markdown>
210221

211-
``` py linenums="1" hl_lines="2 3"
222+
```py linenums="1" hl_lines="2 3"
212223
def bubble_sort(items):
213224
for i in range(len(items)):
214225
for j in range(len(items) - 1 - i):
@@ -224,8 +235,8 @@ Code annotations can be placed anywhere in a code block where a comment for the
224235
language of the block can be placed, e.g. for JavaScript in `#!js // ...` and
225236
`#!js /* ... */`, for YAML in `#!yaml # ...`, etc.:
226237

227-
```` markdown title="Code block with annotation"
228-
``` yaml
238+
````markdown title="Code block with annotation"
239+
```yaml
229240
theme:
230241
features:
231242
- content.code.annotate # (1)!
@@ -243,33 +254,160 @@ theme:
243254
- content.code.annotate # (1)!
244255
```
245256
246-
1. :man_raising_hand: I'm a code annotation! I can contain `code`, __formatted
247-
text__, images, ... basically anything that can be written in Markdown.
257+
1. :man_raising_hand: I'm a code annotation! I can contain `code`, **formatted
258+
text**, images, ... basically anything that can be written in Markdown.
248259

249260
</div>
250261

251262
### Admonitions
252263

253-
[Admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions/) is a great way to emphasize a piece of information. Check the original documentation for all the customizations available for admonitions.
264+
[Admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions/) is a great way to emphasize a piece of information. Here is a list of admonitions you may use most often:
254265

255-
``` markdown title="Admonition"
256-
!!! note
266+
//// tab | Note
257267

258-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
259-
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
260-
massa, nec semper lorem quam in massa.
268+
```markdown
269+
/// note
270+
271+
This is a note
272+
///
261273
```
262274

263275
<div class="result" markdown>
264276

265-
!!! note
277+
/// note
266278

267-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
268-
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
269-
massa, nec semper lorem quam in massa.
279+
This is a note
280+
///
281+
</div>
282+
////
283+
//// tab | Warning
284+
285+
```markdown
286+
/// warning
287+
288+
This is a warning
289+
///
290+
```
291+
292+
<div class="result" markdown>
293+
294+
/// warning
295+
296+
This is a warning
297+
///
298+
</div>
299+
////
300+
//// tab | Tip
301+
302+
```markdown
303+
/// tip
304+
305+
This is a tip
306+
///
307+
```
308+
309+
<div class="result" markdown>
310+
311+
/// tip
312+
313+
This is a tip
314+
///
315+
</div>
316+
////
317+
318+
#### Admonition's title
319+
320+
Often it is desired to name the admonition block to provide some context to the reader. To achieve this, add a title of the admonition to the block type, like this:
321+
322+
```markdown
323+
/// note | This note now has a `title`
324+
This is a note with a title
325+
///
326+
```
327+
328+
<div class="result" markdown>
329+
330+
/// note | This note now has a `title`
331+
This is a note with a title
332+
///
333+
</div>
334+
335+
#### Collapsible admonitions
336+
337+
A perfect way to provide large amounts of auxiliary information is to use a collapsed admonition that will only be displayed when the user clicks on the title.
338+
To make an admonition collapsed, change the block type to `details` and add the `type` of the admonition you want to use.
339+
340+
For example, to make a collapsed Note, use the following code:
341+
342+
```markdown
343+
/// details
344+
type: note
345+
346+
This is a collapsed note
347+
///
348+
```
349+
350+
<div class="result" markdown>
351+
352+
/// details | This collapsed note opens on click
353+
type: note
354+
355+
This is a collapsed note
356+
///
357+
</div>
358+
359+
### Images
360+
361+
To add an image to your post, use the following shortcode:
362+
363+
```markdown
364+
-{{% raw %}}-
365+
-{{image(url='https://gitlab.com/rdodin/pics/-/wikis/uploads/23ce60488a6e1b9b2faf082b2c7be77b/image.png')}}-
366+
-{{% endraw %}}-
367+
```
368+
369+
<div class="result" markdown>
270370

371+
-{{image(url='https://gitlab.com/rdodin/pics/-/wikis/uploads/23ce60488a6e1b9b2faf082b2c7be77b/image.png')}}-
271372
</div>
272373

374+
By default, the image will be displayed in its original size and with a shadow around it.
375+
376+
To control the image width, use the `width` parameter of the short code that sets the width in percentage of the available page width:
377+
378+
```markdown
379+
-{{% raw %}}-
380+
-{{image(url='https://gitlab.com/rdodin/pics/-/wikis/uploads/23ce60488a6e1b9b2faf082b2c7be77b/image.png')}}-
381+
-{{% endraw %}}-
382+
```
383+
384+
<div class="result" markdown>
385+
386+
-{{image(url='https://gitlab.com/rdodin/pics/-/wikis/uploads/23ce60488a6e1b9b2faf082b2c7be77b/image.png', width=30)}}-
387+
</div>
388+
389+
### Diagrams
390+
391+
The drawio/diagrams.net diagramming tool is a great way to create diagrams. Diagrams are better than images in every way. If you invest in creating diagrams instead of generating images, you will be able to version control, and easily edit them as your project evolves.
392+
393+
To embed a diagram, use the following shortcode and add a script element to your page at the bottom:
394+
395+
```markdown
396+
-{{% raw %}}-
397+
-{{ diagram(url='srl-labs/srlinux-getting-started/main/diagrams/get-started.drawio', title='Default SR Linux prompt', page=0) }}-
398+
399+
<script type="text/javascript" src="https://viewer.diagrams.net/js/viewer-static.min.js" async></script>
400+
-{{% endraw %}}-
401+
```
402+
403+
<div class="result">
404+
405+
-{{ diagram(url='srl-labs/srlinux-getting-started/main/diagrams/get-started.drawio', title='Default SR Linux prompt', page=0) }}-
406+
</div>
407+
408+
- The `page` parameter (0-indexed) selects which page in the drawio file to display.
409+
- The `zoom` parameter (integer) sets x-times zoom factor. If your diagran renders too small with the default zoom factor, set it to a higher value.
410+
273411
### Icons
274412

275413
Our doc theme includes a [gazillion of icons](https://squidfunk.github.io/mkdocs-material/reference/icons-emojis/) and emojis which are super easy to use. Use the [search tool](https://squidfunk.github.io/mkdocs-material/reference/icons-emojis/#search) to find the icon code-block and paste it in your post.
@@ -353,3 +491,5 @@ Get notified when a new post is published using one of the [subscription options
353491

354492
[authors-file]: https://github.com/srl-labs/learn-srlinux/blob/main/docs/blog/.authors.yml
355493
[date]: https://github.com/srl-labs/learn-srlinux/blob/main/docs/blog/posts/2022/blog-launch.md?plain=1#L2
494+
495+
<script type="text/javascript" src="https://viewer.diagrams.net/js/viewer-static.min.js" async></script>

0 commit comments

Comments
 (0)