Skip to content

Commit

Permalink
Add Searchbar and Index, Fancy Codeblock, Latex Support (#44)
Browse files Browse the repository at this point in the history
* Update README.md

* Delete .github/workflows/docs.yml

* old shortcodes, update info, first pass of code SCSS and clipboarding

* Get nodes and code clipboards working

* gif shortcode improvement with width

* Add dim. options for newtab shortcode

* Enable clipboard code blocks by default

* Update README

* inline code highlighting, comments

* Make LaTex a config option partial

* Update README

* Initial working search bar support

* Better searchbar styling

* Refine search styling, search index file path resolution

* Update demo pages, update README

* fix: graceful search index path resolution, downsize screenshot

* Youtube and audio shortcodes, search on /, blockquote styling

* Add custom 404 page

* Blockquote bg, toggle theme JS code for later

* Override index title for pages

* Update theme.toml

* Update blockquote styling

* Revert to original author's README, config, and theme files with
additions

* Add back deleted docs workflow

* Update README instruction for codeblocks
  • Loading branch information
micahkepe authored Nov 6, 2024
1 parent 37b4516 commit 1f32860
Show file tree
Hide file tree
Showing 29 changed files with 1,436 additions and 160 deletions.
68 changes: 64 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# after-dark

![after-dark screenshot](https://github.com/getzola/after-dark/blob/master/screenshot.png?raw=true)
![after-dark screenshot](screenshot.png)

## Features

- [x] Code Snippet Clipboards
- [x] Latex Support
- [ ] Light/Dark mode support
- [x] Search functionality

## Contents

Expand All @@ -9,14 +16,19 @@
- [Top menu](#top-menu)
- [Title](#title)
- [Author](#author)
- [Code Snippets](#code-snippets)
- [LaTex Support](#latex-support)
- [Searchbar](#searchbar)

## Installation

First download this theme to your `themes` directory:

```bash
cd themes
git clone https://github.com/getzola/after-dark.git
```

and then enable it in your `config.toml`:

```toml
Expand All @@ -40,13 +52,14 @@ taxonomies = [
{name = "tags", feed = true},
]
```

If you want to paginate taxonomies pages, you will need to overwrite the templates
as it only works for non-paginated taxonomies by default.


## Options

### Top-menu

Set a field in `extra` with a key of `after_dark_menu`:

```toml
Expand All @@ -62,19 +75,24 @@ If you put `$BASE_URL` in a url, it will automatically be replaced by the actual
site URL.

### Title

The site title is shown on the homepage. As it might be different from the `<title>`
element that the `title` field in the config represents, you can set the `after_dark_title`
instead.

### Author

You can set this on a per page basis or in the config file.

`config.toml`:

```toml
[extra]
author = "John Smith"
```

In a page (wrap this in +++):

```toml
title = "..."
date = 1970-01-01
Expand All @@ -83,5 +101,47 @@ date = 1970-01-01
author = "John Smith"
```

## Original
This template is based on the Hugo template https://git.habd.as/comfusion/after-dark
### Code Snippets

Syntax Highlighting:

```toml
[markdown]
# Whether to do syntax highlighting
# Theme can be customized by setting the `highlight_theme` variable to a theme supported by Zola
highlight_code = true

highlight_theme = "one-dark"
```

Enhanced Codeblocks (Clipboard Support and Language Tags)

To enable enhanced codeblocks, set the following in your `config.toml`:

```toml
[extra]
codeblock = true
```

### LaTex Support

To enable LaTeX support with MathJax, set the following in your `config.toml`:

```toml
[extra]
latex = true
```

### Searchbar

To enable a searchbar at the top of the page navigation, set the following in your `config.toml`:

```toml
build_search_index = true

[search]
index_format = "elasticlunr_json"

[extra]
enable_search = true
```
27 changes: 25 additions & 2 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,34 @@ taxonomies = [
{name = "tags", feed = true},
]

# When set to "true", a search index is built from the pages and section
# content for `default_language`.
build_search_index = true

[markdown]
# Whether to do syntax highlighting
# Theme can be customized by setting the `highlight_theme` variable to a theme supported by Zola
highlight_code = true

highlight_theme = "one-dark"

[search]
index_format = "elasticlunr_json"

[extra]
author = "Vincent"
author = "John Doe"
after_dark_menu = [
{url = "$BASE_URL", name = "Home"},
{url = "$BASE_URL/categories", name = "Categories"},
{url = "$BASE_URL/tags", name = "Tags"},
]
after_dark_title = "My blog"
after_dark_title = "My Example Site"

# Nicer codeblocks with copy to clipboard
codeblock = true

# Enable MathJax support
latex = true

# Enable search bar
enable_search = true
51 changes: 51 additions & 0 deletions content/code-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
+++
title = "Code Example"
date = 2017-09-24

[taxonomies]
categories = ["demo"]
tags = ["code", "example"]
+++

Have code snippets complete with **clipboard functionality** and **fancy
language tags**. No more boring code snippets in your pages. Oh yeah baby! Click
on this article to see some code in action.

<!-- more -->

```rust

fn main() {
println!("Hello, world!");
}
```

This is a code block with syntax highlighting. It's pretty cool, right?

```python

def main():
print("Hello, world!")
```

This is another code block with syntax highlighting. It's pretty cool, right?

<!-- prettier-ignore-->
```js

function debounce(func, wait) {
var timeout;

return function () {
var context = this;
var args = arguments;
clearTimeout(timeout);

timeout = setTimeout(function () {
timeout = null;
func.apply(context, args);
}, wait);
};
}

```
85 changes: 85 additions & 0 deletions content/latex-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
+++
title = "LaTeX Example"
date = 2017-09-24

[taxonomies]
categories = ["demo"]
tags = ["latex", "example"]
+++

This theme allows you to use MathJax directly in your Markdown! Click on this
article to see some fancy math in action. Little teaser:
$ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} $

<!-- more -->

Some fancy math thingy:

$$
\begin{align*}
\frac{d}{dx} \left( \int_{0}^{x} f(u) \, du \right) &= f(x) \\
\frac{d}{dx} \left( \int_{g(x)}^{h(x)} f(u) \, du \right) &= f(h(x))h'(x) - f(g(x))g'(x)
\end{align*}
$$

Isn't that cool?!

---

## Another cool thingy

We will prove this statement by induction on $h$.

### Base Case: $h = 0$

The AVL tree of height 0 has no nodes, so $N_0 = 0$. The Fibonacci number $F_{0+2} = F_2 = 1$. Therefore,

$$
N_0 = 0 \geq F_2 - 1 = 1 - 1 = 0
$$

which holds true.

### Base Case: $h = 1$

The AVL tree of height 1 has one node, so $N_1 = 1$. The Fibonacci number $F_{1+2} = F_3 = 2$. Therefore,

$$
N_1 = 1 \geq F_3 - 1 = 2 - 1 = 1
$$

which holds true.

### Inductive Step:

Assume the claim holds true for $h = k$. That is,

$$
N_{k} \geq F_{k+2} - 1 \tag{I.H.}
$$

For $h = k+1$, we know:

$$
N_{k+1} = N_{k} + N_{k-1} + 1 \tag{def. of $N_h$}
$$

From the inductive hypothesis, $N_{k} \geq F_{k+2} - 1$ and $N_{k-1} \geq F_{k+1} - 1$. Substituting:

$$
N_{k+1} = N_{k} + N_{k - 1} + 1 \geq (F_{k+2} - 1) + (F_{k+1} - 1) + 1
$$

Thus, we get:

$$
N_{k+1} \geq F_{k+2} + F_{k+1} - 1
$$

By the definition of Fibonacci numbers:

$$
N_{k+1} \geq F_{k+3} - 1 \tag{def. of Fibonacci}
$$

By the principle of mathematical induction, the statement holds for all $h \geq 0$.
Binary file added content/shortcodes-demo/assets/audio.mp3
Binary file not shown.
Binary file added content/shortcodes-demo/assets/video.mp4
Binary file not shown.
39 changes: 39 additions & 0 deletions content/shortcodes-demo/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
+++
title = "Shortcodes Demos"
date = 2017-09-24

[taxonomies]
categories = ["demo"]
tags = ["gif", "fancy"]
+++

"after-dark" comes with some handy shortcodes to make your life easier and
your posts more exciting.

<!-- more -->

Here are some examples:

# GIF-Suport

Level up your posts with GIFs!

{{ gif(sources=["assets/video.mp4"], width=50)}}

# Fancy Notes

{{ note(body="
**Note:** Some really insightful note here.

$$ \sum\_{i=1}^{n} i = \frac{n(n+1)}{2} $$
")}}

# YouTube Video Embedding

{{ youtube(id="ym3y13nA3ew", width=80) }}

# Audio File Embedding

{{ audio(source="assets/audio.mp3")}}

> If you're still falling for this, I don't know what to tell you.
Loading

0 comments on commit 1f32860

Please sign in to comment.