Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented details tag for distill blog #1321

Merged
merged 2 commits into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions _plugins/details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Code from http://movb.de/jekyll-details-support.html

module Jekyll
module Tags
class DetailsTag < Liquid::Block

def initialize(tag_name, markup, tokens)
super
@caption = markup
end

def render(context)
site = context.registers[:site]
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
caption = converter.convert(@caption).gsub(/<\/?p[^>]*>/, '').chomp
body = converter.convert(super(context))
"<details><summary>#{caption}</summary>#{body}</details>"
end

end
end
end

Liquid::Template.register_tag('details', Jekyll::Tags::DetailsTag)
10 changes: 10 additions & 0 deletions _posts/2018-12-22-distill.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ fig.write_html('assets/plotly/demo.html')

***

## Details boxes

Details boxes are collapsible boxes which hide additional information from the user. They can be added with the `details` liquid tag:

{% details Click here to know more %}
Additional details, where math $$ 2x - 1 $$ and `code` is rendered correctly.
{% enddetails %}

***

## Layouts

The main text column is referred to as the body.
Expand Down
22 changes: 22 additions & 0 deletions _sass/_distill.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ d-article {
display: inline;
}

// Style taken from code blocks
details {
color: var(--global-text-color);
background-color: var(--global-code-bg-color);
margin-top: 0;
padding: 8px 12px;
position: relative;
border-radius: 6px;
display: block;
margin-bottom: 20px;
grid-column: text;
overflow: auto;
max-width: 100%;
summary {
color: var(--global-theme-color);
}
p {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
}

d-contents {
align-self: start;
grid-column: 1 / 4;
Expand Down