Site Slides Generator
Generate presentation slides for the AI training camp website from a directory of images or a PDF file.
Usage
User provides a directory name (e.g., test1), and this skill will:
- Look for the directory in
./site/public/slides/<directory-name>
- If not found, report an error
- If found, process the contents to generate slides
Workflow
Step 1: Validate Directory
Check if the directory exists:
ls ./site/public/slides/<directory-name>
If directory doesn't exist, inform the user and stop.
Step 2: Analyze Contents
Check what's in the directory:
- If there's exactly ONE
.pdf file and no image files → Go to Step 3 (PDF conversion)
- If there are image files (
.jpg, .jpeg, .png, .gif, .webp) → Go to Step 4 (Generate slides)
Step 3: PDF to Images Conversion
If directory contains only a PDF file:
Check if pdf2jpg command exists:
which pdf2jpg
If not found, install swiss-knife:
cargo install swiss-knife
Convert PDF to JPG images:
cd ./site/public/slides/<directory-name> && pdf2jpg <filename>.pdf
This generates 001.jpg, 002.jpg, etc. in the current directory.
Delete the original PDF file after successful conversion (if it still exists).
Since we're still in the slides directory, use the filename directly:
rm -f <filename>.pdf
Note: Use -f flag in case pdf2jpg already deleted the file.
Proceed to Step 4.
Step 4: Generate Slides MDX File
List all image files in sorted order:
ls -1 ./site/public/slides/<directory-name>/*.{jpg,jpeg,png,gif,webp} 2>/dev/null | sort
Read each image to understand its content and generate appropriate captions.
Ask the user for:
- Title: The presentation title (e.g., "Werner Vogels - The Renaissance Developer")
- Description: Brief description of the presentation
- Category: Category for the presentation (e.g., "技术分享", "课程介绍")
Create MDX file at ./site/src/pages/presentations/<directory-name>.mdx following this template:
---
layout: ../../layouts/PresentationLayout.astro
title: <TITLE>
description: <DESCRIPTION>
category: <CATEGORY>
---
import PresentationCarousel from '../../components/presentations/PresentationCarousel';
import { getUrl } from '../../utils/url';
# <TITLE>
<BRIEF_INTRO>
<PresentationCarousel
client:load
title="<TITLE>"
slides={[
{
image: "/slides/<directory-name>/<image-filename>",
alt: "<alt-text>",
caption: "<caption>"
},
// ... more slides
]}
/>
## 核心要点
<KEY_POINTS_BASED_ON_CONTENT>
## 延伸阅读
- [查看课程大纲](/curriculum) - 了解 AI 编程训练营完整内容
- [探索工具生态](/tools) - 学习 AI 编程工具的使用
- [浏览学习资料](/materials) - 获取更多技术学习资源
Step 5: Update index.astro
Read ./site/src/pages/presentations/index.astro
Add a new entry to the presentations array:
{
title: "<TITLE>",
description: "<DESCRIPTION>",
href: getUrl("presentations/<directory-name>"),
thumbnail: getUrl("slides/<directory-name>/<first-image>"),
slideCount: <NUMBER_OF_SLIDES>,
date: "<YYYY-MM-DD>", // Today's date
category: "<CATEGORY>",
},
Use the first image as the thumbnail (or ask the user to pick one).
Example
User: "Create slides from the vogels-keynote directory"
- Check
./site/public/slides/vogels-keynote exists ✓
- Find 32 JPG images
- Ask user for title, description, category
- Read images to understand content
- Generate
./site/src/pages/presentations/vogels-keynote.mdx
- Update
./site/src/pages/presentations/index.astro
Notes
- Always read a sample of images (first, middle, last) to understand the presentation content
- Generate meaningful alt text and captions based on image content
- Use today's date for the
date field in index.astro
- Image paths in the MDX should be absolute paths starting with
/slides/
Important: Avoiding MDX Syntax Errors
When generating captions and alt text, NEVER use Chinese quotation marks (" and ") inside JSX string attributes. These characters cause MDX parsing errors.
Bad example:
caption: "真正的问题不是"AI会取代我吗?"而是..."
Good example (use 「」 instead):
caption: "真正的问题不是「AI会取代我吗?」而是..."
Also avoid:
- Unescaped special characters in strings
- Line breaks within caption strings
- Using backticks or other quote characters that might conflict with JSX syntax
1---2name: site-slides3description: Generate presentation slides from images or PDF files. Use when user wants to create slides, generate presentations, or convert PDF to slides for the training camp website. Triggers on keywords like "slides", "presentation", "幻灯片", "演示文稿".4---5
6# Site Slides Generator
7
8Generate presentation slides for the AI training camp website from a directory of images or a PDF file.
9
10## Usage
11
12User provides a directory name (e.g., `test1`), and this skill will:
131. Look for the directory in `./site/public/slides/<directory-name>`
142. If not found, report an error
153. If found, process the contents to generate slides
16
17## Workflow
18
19### Step 1: Validate Directory
20
21Check if the directory exists:
22```bash
23ls ./site/public/slides/<directory-name>
24```
25
26If directory doesn't exist, inform the user and stop.
27
28### Step 2: Analyze Contents
29
30Check what's in the directory:
31- If there's exactly ONE `.pdf` file and no image files → Go to Step 3 (PDF conversion)
32- If there are image files (`.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`) → Go to Step 4 (Generate slides)
33
34### Step 3: PDF to Images Conversion
35
36If directory contains only a PDF file:
37
381. Check if `pdf2jpg` command exists:
39 ```bash
40 which pdf2jpg
41 ```
42
432. If not found, install swiss-knife:
44 ```bash
45 cargo install swiss-knife
46 ```
47
483. Convert PDF to JPG images:
49 ```bash
50 cd ./site/public/slides/<directory-name> && pdf2jpg <filename>.pdf
51 ```
52
53 This generates `001.jpg`, `002.jpg`, etc. in the current directory.
54
554. Delete the original PDF file after successful conversion (if it still exists).
56 Since we're still in the slides directory, use the filename directly:
57 ```bash
58 rm -f <filename>.pdf
59 ```
60 Note: Use `-f` flag in case `pdf2jpg` already deleted the file.
61
625. Proceed to Step 4.
63
64### Step 4: Generate Slides MDX File
65
661. List all image files in sorted order:
67 ```bash
68 ls -1 ./site/public/slides/<directory-name>/*.{jpg,jpeg,png,gif,webp} 2>/dev/null | sort
69 ```
70
712. Read each image to understand its content and generate appropriate captions.
72
733. Ask the user for:
74 - **Title**: The presentation title (e.g., "Werner Vogels - The Renaissance Developer")
75 - **Description**: Brief description of the presentation
76 - **Category**: Category for the presentation (e.g., "技术分享", "课程介绍")
77
784. Create MDX file at `./site/src/pages/presentations/<directory-name>.mdx` following this template:
79
80```mdx
81---
82layout: ../../layouts/PresentationLayout.astro
83title: <TITLE>
84description: <DESCRIPTION>
85category: <CATEGORY>
86---
87
88import PresentationCarousel from '../../components/presentations/PresentationCarousel';
89import { getUrl } from '../../utils/url';
90
91# <TITLE>
92
93<BRIEF_INTRO>
94
95<PresentationCarousel
96 client:load
97 title="<TITLE>"
98 slides={[
99 {
100 image: "/slides/<directory-name>/<image-filename>",
101 alt: "<alt-text>",
102 caption: "<caption>"
103 },
104 // ... more slides
105 ]}
106/>
107
108## 核心要点
109
110<KEY_POINTS_BASED_ON_CONTENT>
111
112## 延伸阅读
113
114- [查看课程大纲](/curriculum) - 了解 AI 编程训练营完整内容
115- [探索工具生态](/tools) - 学习 AI 编程工具的使用
116- [浏览学习资料](/materials) - 获取更多技术学习资源
117```
118
119### Step 5: Update index.astro
120
1211. Read `./site/src/pages/presentations/index.astro`
122
1232. Add a new entry to the `presentations` array:
124 ```javascript
125 {
126 title: "<TITLE>",
127 description: "<DESCRIPTION>",
128 href: getUrl("presentations/<directory-name>"),
129 thumbnail: getUrl("slides/<directory-name>/<first-image>"),
130 slideCount: <NUMBER_OF_SLIDES>,
131 date: "<YYYY-MM-DD>", // Today's date
132 category: "<CATEGORY>",
133 },
134 ```
135
1363. Use the first image as the thumbnail (or ask the user to pick one).
137
138## Example
139
140User: "Create slides from the `vogels-keynote` directory"
141
1421. Check `./site/public/slides/vogels-keynote` exists ✓
1432. Find 32 JPG images
1443. Ask user for title, description, category
1454. Read images to understand content
1465. Generate `./site/src/pages/presentations/vogels-keynote.mdx`
1476. Update `./site/src/pages/presentations/index.astro`
148
149## Notes
150
151- Always read a sample of images (first, middle, last) to understand the presentation content
152- Generate meaningful alt text and captions based on image content
153- Use today's date for the `date` field in index.astro
154- Image paths in the MDX should be absolute paths starting with `/slides/`
155
156## Important: Avoiding MDX Syntax Errors
157
158When generating captions and alt text, **NEVER use Chinese quotation marks** (`"` and `"`) inside JSX string attributes. These characters cause MDX parsing errors.
159
160**Bad example:**
161```jsx
162caption: "真正的问题不是"AI会取代我吗?"而是..."
163```
164
165**Good example (use 「」 instead):**
166```jsx
167caption: "真正的问题不是「AI会取代我吗?」而是..."
168```
169
170Also avoid:
171- Unescaped special characters in strings
172- Line breaks within caption strings
173- Using backticks or other quote characters that might conflict with JSX syntax