People,
I have been looking at Markdown but it is too basic, so I looked at various other HTML options but I wondered if any Jekyll devs have a better solution . .
I want to produce a nicer-looking, collapsible accordion that can produce an About Page that looks somthing like this:
A Nicer MD Accordion
where the headings in grey have their text and subheadings underneath collapsed - maybe the sub-headings need to be in a smaller point size too . .
Anyone done something like this?
Thanks,
Phil.
You might want to consider using a bootstrap component rather than doing this yourself.
Here’s a conversion where I show you how to set up bootstrap:
Hi there, I feel like I am only answering 1/2 of your question, but since I only know one method, I thought this could at least get you started.
There are two ways to access Bootstrap for any site:
Connect to the CDN, which means your website will connect to an external source to connect to the Bootstrap components. This is the easiest method; you can jump into it immediately with Jekyll.
Download the Bootstrap components and use them on your website. This may include a one-time download, mod…
Here’s a a vertical accordion that I believe contains the features you need:
If you are looking for a pure HTML/CSS/Javascript option, I have not implemented that so hopefully others here have some advice as well.
1 Like
Thanks! I will check that out!
Hmm . . I just had a quick look at the demo and it only has one level in the accordion - ideally I need multiple (unlimited) levels with the indentation I showed in my graphic . . I will keep looking to see if it can do more than one . .
You can embed the accordion inside an accordion. Here is some admittedly quickie code and a screenshot.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nested Accordion Example</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<!-- First level Accordion -->
<div class="accordion" id="accordionExample1">
<div class="card">
<div class="card-header" id="headingOne">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Parent Accordion Item #1
</button>
</h2>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample1">
<div class="card-body">
<!-- Nested Accordion (Second Level) -->
<div class="accordion" id="accordionExample2">
<div class="card">
<div class="card-header" id="headingTwo">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
Nested Accordion Item #1
</button>
</h2>
</div>
<div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#accordionExample2">
<div class="card-body">
This is the first nested accordion content.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingThree">
<h2 class="mb-0">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Nested Accordion Item #2
</button>
</h2>
</div>
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample2">
<div class="card-body">
This is the second nested accordion content.
</div>
</div>
</div>
</div>
<!-- End of Nested Accordion -->
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingFour">
<h2 class="mb-0">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseFour" aria-expanded="false" aria-controls="collapseFour">
Parent Accordion Item #2
</button>
</h2>
</div>
<div id="collapseFour" class="collapse" aria-labelledby="headingFour" data-parent="#accordionExample1">
<div class="card-body">
Parent accordion content for item #2.
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
1 Like
Ah . . of course . . I will look more closely when I get home . .
Thanks!
@BillRaymond ,
Update:
OK, that all went nicely! - thanks again!
Another Q: I thought adding HTML to a MD page like the Jekyll About Page was OK? When I put “### This is a heading” as the first line in the body of your code:
<body>
### Was this ever going to be a thing?
ie with a blank line before and after, it is not processed but just printed out with the hashes like a para - I am missing something I suppose?
Update #2:
Ah . . It looks like I need to get rid of the head and body tags . .
2 Likes