Skip to content

Commit c167d4c

Browse files
committed
Enhance presentation management: Update index.html and automate presentations array generation
1 parent 271aabd commit c167d4c

File tree

5 files changed

+179
-42
lines changed

5 files changed

+179
-42
lines changed

Taskfile.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ tasks:
3838
echo "✅ Created new presentation: ${SLUG}"
3939
echo "📂 Location: ${PRES_DIR}"
4040
echo "🌐 Will be available at: /${SLUG}/"
41+
- task: update-index
42+
- |
43+
echo ""
44+
echo "📋 Updated index.html with new presentation"
4145
echo ""
4246
echo "Next steps:"
43-
echo " 1. Edit ${PRES_DIR}/slides.md to add your slides (Markdown format)"
47+
echo " 1. Edit {{.CLI_ARGS}}/slides.md to add your slides (Markdown format)"
4448
echo " 2. Run 'task serve' to preview locally"
45-
echo " 3. View at http://localhost:{{.SERVER_PORT}}/${SLUG}/"
49+
echo " 3. View at http://localhost:{{.SERVER_PORT}}/{{.CLI_ARGS}}/"
4650
4751
list:
4852
desc: List all presentations
@@ -67,7 +71,7 @@ tasks:
6771
fi
6872
6973
update-index:
70-
desc: Generate presentations array for index.html
74+
desc: Update index.html with current presentations list
7175
cmds:
7276
- ./scripts/update-index.sh
7377

index.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,8 @@ <h1>📊 Presentations</h1>
142142
// For GitHub Pages, we'll need to maintain a list of presentations
143143
// This can be updated manually or via a build script
144144
const presentations = [
145-
{
146-
slug: 'getting-started',
147-
title: 'Getting Started',
148-
description: 'Learn how to create and manage presentations with reveal.js'
149-
}
145+
{ slug: 'getting-started', title: 'Getting Started', description: 'Click to view presentation' },
146+
{ slug: 'intro', title: 'intro', description: 'Click to view presentation' }
150147
];
151148

152149
if (presentations.length === 0) {
@@ -155,7 +152,7 @@ <h1>📊 Presentations</h1>
155152
<h2>No Presentations Yet</h2>
156153
<p>Get started by creating your first presentation:</p>
157154
<p><code>task new -- my-first-presentation</code></p>
158-
<p>Then add it to the presentations array in index.html</p>
155+
<p>Your presentation will automatically appear on this page!</p>
159156
</div>
160157
`;
161158
return;

intro/index.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>intro - Codebase Interface</title>
7+
<link rel="stylesheet" href="../lib/reveal.js/dist/reset.css">
8+
<link rel="stylesheet" href="../lib/reveal.js/dist/reveal.css">
9+
<link rel="stylesheet" href="../lib/reveal.js/dist/theme/black.css">
10+
<link rel="stylesheet" href="../lib/reveal.js/plugin/highlight/monokai.css">
11+
</head>
12+
<body>
13+
<div class="reveal">
14+
<div class="slides">
15+
<!-- Markdown content loaded from slides.md -->
16+
<section data-markdown="slides.md"
17+
data-separator="^\n---\n$"
18+
data-separator-vertical="^\n--\n$"
19+
data-separator-notes="^Note:"
20+
data-charset="utf-8">
21+
</section>
22+
</div>
23+
</div>
24+
25+
<script src="../lib/reveal.js/dist/reveal.js"></script>
26+
<script src="../lib/reveal.js/plugin/notes/notes.js"></script>
27+
<script src="../lib/reveal.js/plugin/markdown/markdown.js"></script>
28+
<script src="../lib/reveal.js/plugin/highlight/highlight.js"></script>
29+
<script>
30+
Reveal.initialize({
31+
hash: true,
32+
plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ],
33+
// Presentation settings
34+
controls: true,
35+
progress: true,
36+
center: true,
37+
transition: 'slide', // none/fade/slide/convex/concave/zoom
38+
});
39+
</script>
40+
</body>
41+
</html>

intro/slides.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# intro
2+
3+
A presentation by Codebase Interface
4+
5+
---
6+
7+
## Welcome
8+
9+
This is a sample slide. Edit this file to create your presentation.
10+
11+
Use `---` to separate slides horizontally.
12+
13+
---
14+
15+
## Vertical Slides
16+
17+
Press down arrow for more
18+
19+
--
20+
21+
## Nested Slide 1
22+
23+
You can create vertical slide stacks
24+
25+
Use `--` to separate slides vertically.
26+
27+
--
28+
29+
## Nested Slide 2
30+
31+
Navigate with arrow keys
32+
33+
---
34+
35+
## Code Examples
36+
37+
```javascript
38+
function hello() {
39+
console.log("Hello, World!");
40+
}
41+
```
42+
43+
Code blocks are automatically syntax highlighted!
44+
45+
---
46+
47+
## Lists and Formatting
48+
49+
- **Bold text** with `**text**`
50+
- *Italic text* with `*text*`
51+
- `Inline code` with backticks
52+
- [Links](https://codebaseinterface.org)
53+
54+
---
55+
56+
## Fragment Animations
57+
58+
- Item 1 <!-- .element: class="fragment" -->
59+
- Item 2 <!-- .element: class="fragment" -->
60+
- Item 3 <!-- .element: class="fragment" -->
61+
62+
Note:
63+
These are speaker notes. They won't appear on the slides.
64+
Press 'S' during the presentation to view them.
65+
66+
---
67+
68+
## Thank You!
69+
70+
Visit [codebaseinterface.org](https://codebaseinterface.org)

scripts/update-index.sh

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,64 @@
11
#!/bin/bash
2-
# Script to list presentations for index.html
3-
# This generates a JSON array that can be copied into index.html
2+
# Script to automatically update presentations array in index.html
43

5-
echo "// Copy this array into index.html:"
6-
echo "const presentations = ["
7-
8-
first=true
9-
for dir in presentations/*/; do
10-
if [ -d "$dir" ]; then
11-
name=$(basename "$dir")
12-
13-
if [ "$first" = true ]; then
14-
first=false
15-
else
16-
echo ","
17-
fi
18-
19-
# Extract title from the presentation's index.html if possible
20-
title_file="$dir/index.html"
21-
if [ -f "$title_file" ]; then
22-
# Try to extract the first h1 tag
23-
title=$(grep -m 1 "<h1>" "$title_file" | sed 's/.*<h1>\(.*\)<\/h1>.*/\1/' | sed 's/^[[:space:]]*//')
24-
if [ -z "$title" ]; then
25-
# Fallback to name if no h1 found
26-
title="$name"
4+
# Generate presentations array
5+
generate_presentations_array() {
6+
echo "["
7+
8+
first=true
9+
for dir in */; do
10+
if [ -d "$dir" ] && [ -f "${dir}index.html" ] && [ -f "${dir}slides.md" ]; then
11+
name=$(basename "$dir")
12+
# Skip known system directories
13+
if [[ "$name" != "lib" && "$name" != "node_modules" && "$name" != ".git" && "$name" != "templates" && "$name" != "scripts" && "$name" != "presentations" ]]; then
14+
if [ "$first" = true ]; then
15+
first=false
16+
else
17+
echo ","
18+
fi
19+
20+
# Extract title from slides.md first line or use formatted name
21+
title_file="$dir/slides.md"
22+
if [ -f "$title_file" ]; then
23+
# Try to extract title from first line (assuming it's # Title)
24+
title=$(head -n 1 "$title_file" | sed 's/^#\+[[:space:]]*//')
25+
if [ -z "$title" ] || [ "$title" = "$(head -n 1 "$title_file")" ]; then
26+
# Format the slug as title if no markdown title found
27+
title=$(echo "$name" | sed 's/-/ /g' | sed 's/\b\w/\U&/g')
28+
fi
29+
else
30+
# Format the slug as title
31+
title=$(echo "$name" | sed 's/-/ /g' | sed 's/\b\w/\U&/g')
32+
fi
33+
34+
echo -n " { "
35+
echo -n "slug: '$name', "
36+
echo -n "title: '$title', "
37+
echo -n "description: 'Click to view presentation' "
38+
echo -n "}"
2739
fi
28-
else
29-
title="$name"
3040
fi
31-
32-
echo -n " { slug: '$name', title: '$title', description: 'Add description here' }"
41+
done
42+
43+
echo ""
44+
echo " ]"
45+
}
46+
47+
# Update index.html with new presentations array
48+
temp_file=$(mktemp)
49+
in_presentations_array=false
50+
51+
while IFS= read -r line; do
52+
if [[ $line =~ ^[[:space:]]*const[[:space:]]+presentations[[:space:]]*=[[:space:]]*\[ ]]; then
53+
echo " const presentations = $(generate_presentations_array);"
54+
in_presentations_array=true
55+
elif [[ $in_presentations_array == true && $line =~ "];" ]]; then
56+
in_presentations_array=false
57+
# Skip this line as it's already included in our generated array
58+
elif [[ $in_presentations_array == false ]]; then
59+
echo "$line"
3360
fi
34-
done
61+
done < index.html > "$temp_file"
3562

36-
echo ""
37-
echo "];"
38-
echo ""
39-
echo "Update index.html with the above array!"
63+
mv "$temp_file" index.html
64+
echo "✅ Updated index.html with current presentations"

0 commit comments

Comments
 (0)