From e726014585409acacef2e79a8d83a55a9e47ecb6 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 31 May 2021 16:10:50 +0300 Subject: add more examples, update README --- README.md | 23 ++++++++++++++++------- _posts/2021-04-07-plain.md | 15 +++++++++++++++ _posts/2021-04-08-mathjax.md | 17 +++++++++++++++++ _posts/2021-04-08-test-post1.md | 15 --------------- _posts/2021-04-08-test-post2.md | 15 --------------- _posts/2021-04-09-snippets.md | 21 +++++++++++++++++++++ _posts/2021-04-09-test-post3.md | 24 ------------------------ _posts/2021-04-10-collapsible.md | 22 ++++++++++++++++++++++ _posts/snippets/hello.cpp | 7 +++++++ _posts/snippets/hello.hpp | 3 +++ _posts/snippets/snippet.cpp | 7 ------- _posts/snippets/snippet.hpp | 3 --- _posts/snippets/world.cpp | 7 +++++++ _posts/snippets/world.hpp | 3 +++ index.md | 6 ++++-- 15 files changed, 115 insertions(+), 73 deletions(-) create mode 100644 _posts/2021-04-07-plain.md create mode 100644 _posts/2021-04-08-mathjax.md delete mode 100644 _posts/2021-04-08-test-post1.md delete mode 100644 _posts/2021-04-08-test-post2.md create mode 100644 _posts/2021-04-09-snippets.md delete mode 100644 _posts/2021-04-09-test-post3.md create mode 100644 _posts/2021-04-10-collapsible.md create mode 100644 _posts/snippets/hello.cpp create mode 100644 _posts/snippets/hello.hpp delete mode 100644 _posts/snippets/snippet.cpp delete mode 100644 _posts/snippets/snippet.hpp create mode 100644 _posts/snippets/world.cpp create mode 100644 _posts/snippets/world.hpp diff --git a/README.md b/README.md index 9609954..5afec0c 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ My [Jekyll] theme. I use it for [egor-tensin.github.io], [blog], [sorting-algorithms]. [Jekyll]: https://jekyllrb.com/ -[egor-tensin.github.io]: https://github.com/egor-tensin/egor-tensin.github.io -[blog]: https://github.com/egor-tensin/blog/tree/gh-pages -[sorting-algorithms]: https://github.com/egor-tensin/sorting-algorithms/tree/gh-pages +[egor-tensin.github.io]: https://egor-tensin.github.io/ +[blog]: https://egor-tensin.github.io/blog/ +[sorting-algorithms]: https://egor-tensin.github.io/sorting-algorithms/ Preview ------- @@ -93,10 +93,12 @@ Simply including categories/categories.html should do the job. ### Code snippets -See [Test post 3] for an example of how to conveniently embed snippets in your -pages. +See [this post][snippets] for an example of how to conveniently embed code +snippets in your pages. Basically, you need to put something like this in the front matter: +[snippets]: _posts/2021-04-09-snippets.md + ``` snippets_root_directory: snippets snippets_language: c++ @@ -109,8 +111,6 @@ snippets: - world.cpp ``` -[Test post 3]: _posts/2021-04-09-test-post3.md - And then you can just format an entire section of snippets using a single `include`: @@ -120,6 +120,11 @@ And then you can just format an entire section of snippets using a single The line above would output both hello.hpp and hello.cpp to the page. +Code snippets can be hidden in collapsible panels. +See [this post][collapsible] for an example. + +[collapsible]: _posts/2021-04-10-collapsible.md + ### Typesetting math [MathJax] can be used to typeset mathematics using LaTeX. @@ -140,6 +145,10 @@ $$ Behind the scenes, Kramdown transforms these to `\(...\)` and `\[...\]` sequences, to be processed by MathJax. +See [this post][mathjax post] for a usage example. + +[mathjax post]: _posts/2021-04-08-mathjax.md + History ------- diff --git a/_posts/2021-04-07-plain.md b/_posts/2021-04-07-plain.md new file mode 100644 index 0000000..362fc89 --- /dev/null +++ b/_posts/2021-04-07-plain.md @@ -0,0 +1,15 @@ +--- +title: Plain text +excerpt: > + Just some placeholder text. +category: Life +--- +Pellentesque et lacus eget lacus laoreet eleifend eu in nunc. +Praesent ornare aliquam dui, vitae maximus lorem. +Donec semper nisi nisi, ac ultrices enim maximus quis. +Vivamus sollicitudin facilisis nulla in auctor. +Fusce massa sapien, congue et dictum sed, pretium sed magna. +Vestibulum vulputate, quam vitae suscipit iaculis, ligula purus luctus quam, in +pharetra ex nisl non sapien. +Praesent auctor dignissim ligula, interdum hendrerit urna finibus aliquam. +Praesent neque turpis, porttitor id hendrerit non, luctus et ligula. diff --git a/_posts/2021-04-08-mathjax.md b/_posts/2021-04-08-mathjax.md new file mode 100644 index 0000000..c521f54 --- /dev/null +++ b/_posts/2021-04-08-mathjax.md @@ -0,0 +1,17 @@ +--- +title: MathJax +excerpt: > + Awesome MathJax-powered math! +category: Work +mathjax: true +--- +Today, we'll "prove" that $$2 \times 2 \ne 5$$. + +$$ +\begin{gather} +2 \times 2 = 2 + 2 = 4 \\ +4 \ne 5 \implies 2 \times 2 \ne 5 +\end{gather} +$$ + +Q.E.D. diff --git a/_posts/2021-04-08-test-post1.md b/_posts/2021-04-08-test-post1.md deleted file mode 100644 index 2ec56a9..0000000 --- a/_posts/2021-04-08-test-post1.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: Test post 1 -excerpt: > - This is test post #1. -category: Work ---- -Lorem ipsum dolor sit amet, consectetur adipiscing elit. -Vivamus rutrum cursus lorem, et feugiat arcu porttitor eget. -Praesent laoreet odio orci. -Aliquam vel sodales risus, nec auctor elit. -Interdum et malesuada fames ac ante ipsum primis in faucibus. -Donec nec pulvinar tellus, id pellentesque arcu. -Vestibulum id dapibus velit. -Nam non consequat libero. -Suspendisse euismod purus vitae luctus molestie. diff --git a/_posts/2021-04-08-test-post2.md b/_posts/2021-04-08-test-post2.md deleted file mode 100644 index ee0e0a2..0000000 --- a/_posts/2021-04-08-test-post2.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: Test post 2 -excerpt: > - This is test post #2. -category: Life ---- -Pellentesque et lacus eget lacus laoreet eleifend eu in nunc. -Praesent ornare aliquam dui, vitae maximus lorem. -Donec semper nisi nisi, ac ultrices enim maximus quis. -Vivamus sollicitudin facilisis nulla in auctor. -Fusce massa sapien, congue et dictum sed, pretium sed magna. -Vestibulum vulputate, quam vitae suscipit iaculis, ligula purus luctus quam, in -pharetra ex nisl non sapien. -Praesent auctor dignissim ligula, interdum hendrerit urna finibus aliquam. -Praesent neque turpis, porttitor id hendrerit non, luctus et ligula. diff --git a/_posts/2021-04-09-snippets.md b/_posts/2021-04-09-snippets.md new file mode 100644 index 0000000..f76845a --- /dev/null +++ b/_posts/2021-04-09-snippets.md @@ -0,0 +1,21 @@ +--- +title: Code snippets +excerpt: > + Easily include code snippets in your posts. +snippets_root_directory: snippets +snippets_language: c++ +snippets: + hello: + - hello.hpp + - hello.cpp + world: + - world.hpp + - world.cpp +--- +It's pretty simple, just use the corresponding include: + +{% include snippets/section.html section_id='hello' %} + +This is another set of snippets: + +{% include snippets/section.html section_id='world' %} diff --git a/_posts/2021-04-09-test-post3.md b/_posts/2021-04-09-test-post3.md deleted file mode 100644 index a1ca425..0000000 --- a/_posts/2021-04-09-test-post3.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: Test post 3 -excerpt: > - This is test post #3. With snippets! -snippets_root_directory: snippets -snippets_language: c++ -snippets: - hello: - - snippet.hpp - - snippet.cpp ---- -Aenean ex ipsum, feugiat vel tortor sit amet, dictum facilisis dui. -Pellentesque commodo leo at eros elementum porta. -Aenean ac mauris risus. -Nam nec mattis orci. -Class aptent taciti sociosqu ad litora torquent per conubia nostra, per -inceptos himenaeos. -Duis rutrum turpis leo, sit amet cursus tellus tincidunt et. -Nullam eget tortor nisl. -Class aptent taciti sociosqu ad litora torquent per conubia nostra, per -inceptos himenaeos. -Pellentesque posuere nunc a purus eleifend pulvinar. - -{% include snippets/section.html section_id='hello' %} diff --git a/_posts/2021-04-10-collapsible.md b/_posts/2021-04-10-collapsible.md new file mode 100644 index 0000000..17b82a3 --- /dev/null +++ b/_posts/2021-04-10-collapsible.md @@ -0,0 +1,22 @@ +--- +title: Collapsible snippets +excerpt: > + Snippets can be hidden in collapsible panels. +snippets_root_directory: snippets +snippets_language: c++ +snippets_collapsible: true +snippets: + hello: + - hello.hpp + - hello.cpp + world: + - world.hpp + - world.cpp +--- +Just set a front matter value, and voilĂ ! + +{% include snippets/section.html section_id='hello' %} + +This is another set of snippets: + +{% include snippets/section.html section_id='world' %} diff --git a/_posts/snippets/hello.cpp b/_posts/snippets/hello.cpp new file mode 100644 index 0000000..2f96a60 --- /dev/null +++ b/_posts/snippets/hello.cpp @@ -0,0 +1,7 @@ +#include "world.hpp" + +#include + +void hello_snippets() { + std::cout << "Hello snippets!\n"; +} diff --git a/_posts/snippets/hello.hpp b/_posts/snippets/hello.hpp new file mode 100644 index 0000000..46556b6 --- /dev/null +++ b/_posts/snippets/hello.hpp @@ -0,0 +1,3 @@ +#pragma once + +void hello_snippets(); diff --git a/_posts/snippets/snippet.cpp b/_posts/snippets/snippet.cpp deleted file mode 100644 index bc4122e..0000000 --- a/_posts/snippets/snippet.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "snippet.hpp" - -#include - -void hello_snippets() { - std::cout << "Hello snippets!\n"; -} diff --git a/_posts/snippets/snippet.hpp b/_posts/snippets/snippet.hpp deleted file mode 100644 index 46556b6..0000000 --- a/_posts/snippets/snippet.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void hello_snippets(); diff --git a/_posts/snippets/world.cpp b/_posts/snippets/world.cpp new file mode 100644 index 0000000..54d3807 --- /dev/null +++ b/_posts/snippets/world.cpp @@ -0,0 +1,7 @@ +#include "world.hpp" + +#include + +void hello_world() { + std::cout << "Hello world!\n"; +} diff --git a/_posts/snippets/world.hpp b/_posts/snippets/world.hpp new file mode 100644 index 0000000..32258b1 --- /dev/null +++ b/_posts/snippets/world.hpp @@ -0,0 +1,3 @@ +#pragma once + +void hello_world(); diff --git a/index.md b/index.md index 9c8e09d..e1d916e 100644 --- a/index.md +++ b/index.md @@ -8,5 +8,7 @@ navbar: This is a theme preview. Check out these: -* [the posts feed]({{ '/feed/' | relative_url }}), -* [a post with snippets in it]({{ site.baseurl }}{% post_url 2021-04-09-test-post3 %}). +* [post feed]({{ '/feed/' | relative_url }}), +* [post with MathJax formulas]({{ site.baseurl }}{% post_url 2021-04-08-mathjax %}), +* [post with code snippets]({{ site.baseurl }}{% post_url 2021-04-09-snippets %}), +* [post with collapsible code snippets]({{ site.baseurl }}{% post_url 2021-04-10-collapsible %}). -- cgit v1.2.3