Skip to content

Commit 8440d42

Browse files
committed
docs: add tutorial and example for new features
1 parent 6fa1777 commit 8440d42

File tree

2 files changed

+106
-70
lines changed

2 files changed

+106
-70
lines changed

_posts/2019-08-08-text-and-typography.md

Lines changed: 50 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ math: true
88
mermaid: true
99
image:
1010
path: /commons/devices-mockup.png
11-
width: 800
12-
height: 500
11+
lqip: data:image/webp;base64,UklGRpoAAABXRUJQVlA4WAoAAAAQAAAADwAABwAAQUxQSDIAAAARL0AmbZurmr57yyIiqE8oiG0bejIYEQTgqiDA9vqnsUSI6H+oAERp2HZ65qP/VIAWAFZQOCBCAAAA8AEAnQEqEAAIAAVAfCWkAALp8sF8rgRgAP7o9FDvMCkMde9PK7euH5M1m6VWoDXf2FkP3BqV0ZYbO6NA/VFIAAAA
1312
alt: Responsive rendering of Chirpy theme on multiple devices.
1413
---
1514

1615
This post is to show Markdown syntax rendering on [**Chirpy**](https://github.com/cotes2020/jekyll-theme-chirpy/fork), you can also use it as an example of writing. Now, let's start looking at text and typography.
1716

18-
1917
## Titles
2018
---
2119
# H1 - heading
@@ -26,7 +24,6 @@ This post is to show Markdown syntax rendering on [**Chirpy**](https://github.co
2624

2725
<h4>H4 - heading</h4>
2826
---
29-
<br>
3027

3128
## Paragraph
3229

@@ -95,35 +92,49 @@ Moon
9592

9693
Click the hook will locate the footnote[^footnote], and here is another footnote[^fn-nth-2].
9794

98-
## Images
95+
## Inline code
9996

100-
- Default (with caption)
97+
This is an example of `Inline Code`.
10198

102-
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" }
103-
_Full screen width and center alignment_
99+
## Filepath
104100

105-
<br>
101+
Here is the `/path/to/the/file.extend`{: .filepath}.
106102

107-
- Shadow
103+
## Code blocks
108104

109-
![Window shadow](/posts/20190808/window.png){: .shadow width="1548" height="864" .w-75 }
110-
_shadow effect (visible in light mode)_
105+
### Common
111106

112-
<br>
107+
```
108+
This is a common code snippet, without syntax highlight and line number.
109+
```
113110

114-
- Left aligned
111+
### Specific Language
115112

116-
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-75 .normal}
113+
```bash
114+
if [ $? -ne 0 ]; then
115+
echo "The command was not successful.";
116+
#do the needful / exit
117+
fi;
118+
```
117119

118-
- Float to left
120+
### Specific filename
121+
122+
```sass
123+
@import
124+
"colors/light-typography",
125+
"colors/dark-typography"
126+
```
127+
{: file='_sass/jekyll-theme-chirpy.scss'}
119128

120-
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .left}
121-
Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum. Phasellus a tortor aliquam, tristique felis sit amet, elementum enim. Integer vestibulum vitae nulla nec pretium.
129+
## Mathematics
130+
131+
The mathematics powered by [**MathJax**](https://www.mathjax.org/):
132+
133+
$$ \sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6} $$
122134

123-
- Float to right
135+
When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are
124136

125-
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .right}
126-
Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum. Phasellus a tortor aliquam, tristique felis sit amet, elementum enim. Integer vestibulum vitae nulla nec pretium.
137+
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$
127138

128139
## Mermaid SVG
129140

@@ -135,59 +146,37 @@ _shadow effect (visible in light mode)_
135146
cherry :active, c, after b a, 1d
136147
```
137148

138-
## Mathematics
139-
140-
The mathematics powered by [**MathJax**](https://www.mathjax.org/):
149+
## Images
141150

142-
$$ \sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6} $$
151+
### Default (with caption)
143152

144-
When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are
153+
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" }
154+
_Full screen width and center alignment_
145155

146-
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$
156+
### Left aligned
147157

148-
## Inline code
158+
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-75 .normal}
149159

150-
This is an example of `Inline Code`.
160+
### Float to left
151161

152-
## Filepath
162+
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .left}
163+
Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum.
153164

154-
Here is the `/path/to/the/file.extend`{: .filepath}.
165+
### Float to right
155166

156-
## Code block
167+
![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .right}
168+
Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum.
157169

158-
### Common
170+
### Dark/Light mode & Shadow
159171

160-
```
161-
This is a common code snippet, without syntax highlight and line number.
162-
```
172+
The image below will toggle dark/light mode based on theme preference, notice it has shadows.
163173

164-
### Specific Languages
174+
![light mode only](/posts/20190808/devtools-light.png){: .light .w-75 .shadow .rounded-10 w='1212' h='668' }
175+
![dark mode only](/posts/20190808/devtools-dark.png){: .dark .w-75 .shadow .rounded-10 w='1212' h='668' }
165176

166-
#### Console
177+
## Video
167178

168-
```console
169-
$ env |grep SHELL
170-
SHELL=/usr/local/bin/bash
171-
PYENV_SHELL=bash
172-
```
173-
174-
#### Shell
175-
176-
```bash
177-
if [ $? -ne 0 ]; then
178-
echo "The command was not successful.";
179-
#do the needful / exit
180-
fi;
181-
```
182-
183-
### Specific filename
184-
185-
```sass
186-
@import
187-
"colors/light-typography",
188-
"colors/dark-typography"
189-
```
190-
{: file='_sass/jekyll-theme-chirpy.scss'}
179+
{% include embed/youtube.html id='Balreaj8Yqs' %}
191180

192181
## Reverse Footnote
193182

_posts/2019-08-08-write-a-new-post.md

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tags: [writing]
77
render_with_liquid: false
88
---
99

10-
This post will guide you how to write a post on _Chirpy_ theme. Even if you have previous experience with Jekyll, this article is worth reading, because many features require specific variables to be set.
10+
This tutorial will guide you how to write a post in the _Chirpy_ template, and it's worth reading even if you've used Jekyll before, as many features require specific variables to be set.
1111

1212
## Naming and Path
1313

@@ -177,9 +177,18 @@ By default, the image is centered, but you can specify the position by using one
177177
```
178178
{: .nolineno}
179179

180+
### Dark/Light mode
181+
182+
You can make images follow theme preferences in dark/light mode. This requires you to prepare two images, one for dark mode and one for light mode, and then assign them a specific class (`dark` or `light`):
183+
184+
```markdown
185+
![Light mode only](/path/to/light-mode.png){: .light }
186+
![Dark mode only](/path/to/dark-mode.png){: .dark }
187+
```
188+
180189
### Shadow
181190

182-
The screenshots of the program window can be considered to show the shadow effect, and the shadow will be visible in the `light` mode:
191+
The screenshots of the program window can be considered to show the shadow effect:
183192

184193
```markdown
185194
![Desktop View](/assets/img/sample/mockup.png){: .shadow }
@@ -209,7 +218,7 @@ The parsing result will automatically add the CDN prefix `https://cdn.com` befor
209218
```html
210219
<img src="https://cdn.com/path/to/flower.png" alt="The flower">
211220
```
212-
{: .nolineno}
221+
{: .nolineno }
213222

214223
### Image Path
215224

@@ -220,7 +229,6 @@ When a post contains many images, it will be a time-consuming task to repeatedly
220229
img_path: /img/path/
221230
---
222231
```
223-
{: .nolineno }
224232

225233
And then, the image source of Markdown can write the file name directly:
226234

@@ -238,28 +246,49 @@ The output will be:
238246

239247
### Preview Image
240248

241-
If you want to add an image to the top of the post contents, specify the attribute `path`, `width`, `height`, and `alt` for the image:
249+
If you want to add an image at the top of the article, please provide an image with a resolution of `1200 x 630`. Please note that if the image aspect ratio does not meet `1.91 : 1`, the image will be scaled and cropped.
250+
251+
Knowing these prerequisites, you can start setting the image's attribute:
242252

243253
```yaml
244254
---
245255
image:
246256
path: /path/to/image
247-
width: 1000 # in pixels
248-
height: 400 # in pixels
249257
alt: image alternative text
250258
---
251259
```
252260

253-
Except for `alt`, all other options are necessary, especially the `width` and `height`, which are related to user experience and web page loading performance. The above section "[Size](#size)" also mentions this.
254-
255261
Starting from _Chirpy v5.0.0_, the attributes `height` and `width` can be abbreviated: `height` → `h`, `width` → `w`. In addition, the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name.
256262

257263
For simple use, you can also just use `image` to define the path.
258264

259265
```yml
266+
---
260267
image: /path/to/image
268+
---
269+
```
270+
271+
### LQIP
272+
273+
For preview images:
274+
275+
```yaml
276+
---
277+
image:
278+
lqip: /path/to/lqip-file # or base64 URI
279+
---
261280
```
262281

282+
> You can observe LQIP in the preview image of post [_Text and Typography_](/posts/text-and-typography/).
283+
284+
285+
For normal images:
286+
287+
```markdown
288+
![Image description](/path/to/image){: lqip="/path/to/lqip-file" }
289+
```
290+
{: .nolineno }
291+
263292
## Pinned Posts
264293

265294
You can pin one or more posts to the top of the home page, and the fixed posts are sorted in reverse order according to their release date. Enable by:
@@ -357,6 +386,24 @@ If you want to display the **Liquid** snippet, surround the liquid code with `{%
357386

358387
Or adding `render_with_liquid: false` (Requires Jekyll 4.0 or higher) to the post's YAML block.
359388

389+
## Videos
390+
391+
You can embed a video with the following syntax:
392+
393+
```liquid
394+
{% include embed/{Platform}.html id='{ID}' %}
395+
```
396+
Where `Platform` is the lowercase of the platform name, and `ID` is the video ID.
397+
398+
The following table shows how to get the two parameters we need in a given video URL, and you can also know the currently supported video platforms.
399+
400+
| Video URL | Platform | ID |
401+
|----------------------------------------------------------------------------------------------------|-----------|:--------------|
402+
| [https://www.**youtube**.com/watch?v=**H-B46URT4mg**](https://www.youtube.com/watch?v=H-B46URT4mg) | `youtube` | `H-B46URT4mg` |
403+
| [https://www.**twitch**.tv/videos/**1634779211**](https://www.twitch.tv/videos/1634779211) | `twitch` | `1634779211` |
404+
405+
406+
360407
## Learn More
361408

362409
For more knowledge about Jekyll posts, visit the [Jekyll Docs: Posts](https://jekyllrb.com/docs/posts/).

0 commit comments

Comments
 (0)