Skip to content
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
8 changes: 2 additions & 6 deletions examples/sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ headings:

## Markdown to Figma Slides

### Agenda

- Introduction
- Features
- Demo
- Q&A
2025.12.31
Jone Doe

---

Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ interface BackgroundYamlConfig {
* Full slide configuration from YAML frontmatter
*/
export interface SlideConfig {
/**
* Treat the first slide as a cover slide (global frontmatter only).
* Default: true
*/
cover?: boolean;
/**
* Background configuration - unified property that accepts:
* - String: auto-detected as color, gradient, image, or Figma component
Expand Down
30 changes: 30 additions & 0 deletions packages/cli/src/markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,36 @@ Text`);
});
});

describe("cover frontmatter", () => {
it("should mark the first slide as cover by default", () => {
const result = parseMarkdown(`# Title

---

## Slide 2`);

expect(result).toHaveLength(2);
expect(result[0].cover).toBe(true);
expect(result[1].cover).toBeUndefined();
});

it("should disable cover when cover: false is set in global frontmatter", () => {
const result = parseMarkdown(`---
cover: false
---

# Title

---

## Slide 2`);

expect(result).toHaveLength(2);
expect(result[0].cover).toBeUndefined();
expect(result[1].cover).toBeUndefined();
});
});

describe("footnotes", () => {
it("parses footnote references in text", () => {
const result = parseMarkdown(`## Test
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ export function parseMarkdown(
let globalDefaultAlign: HorizontalAlign | undefined;
let globalDefaultValign: VerticalAlign | undefined;
let globalDefaultTransition: SlideTransitionConfig | undefined;
let globalCoverEnabled = true;
let contentWithoutGlobalFrontmatter = processedMarkdown;
const slides: SlideContent[] = [];

Expand All @@ -812,6 +813,9 @@ export function parseMarkdown(
if (frontmatterMatch) {
try {
const config = parseYaml(frontmatterMatch[1]) as SlideConfig;
if (typeof config.cover === "boolean") {
globalCoverEnabled = config.cover;
}
const {
background,
styles,
Expand Down Expand Up @@ -861,5 +865,9 @@ export function parseMarkdown(
}
}

if (globalCoverEnabled && slides.length > 0) {
slides[0].cover = true;
}

return slides;
}
1 change: 1 addition & 0 deletions packages/docs/src/content/docs/en/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ color: "#58a6ff"

| Property | Type | Description |
|----------|------|-------------|
| `cover` | `boolean` | Treat the first slide as a cover (default: `true`) |
| `background` | `string \| object` | Unified background config: string (color/gradient/image/component) or object (`color`, `gradient`, `template`, `image`, `component`) |
| `color` | `string` | Base text color (applied to all elements) |
| `headings` | `object` | Heading styles (h1-h4) |
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/content/docs/en/markdown-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Back to global settings (dark background, dissolve)
| Setting | Description |
|---------|-------------|
| `figdeck` | Enable VSCode extension features (`true`/`false`) |
| `cover` | Treat the first slide as a cover (`true`/`false`, default: `true`) |
| `background` | Unified background: color, gradient, image, template, or Figma component |
| `color` | Base text color |
| `headings` | Heading styles (h1, h2, h3, h4) |
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/content/docs/ja/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ color: "#58a6ff"

| プロパティ | 型 | 説明 |
|------------|------|------|
| `cover` | `boolean` | 1枚目を表紙として扱う(デフォルト: `true`) |
| `background` | `string \| object` | 統一された背景設定: string(色/グラデーション/画像/コンポーネント)または object(`color`, `gradient`, `template`, `image`, `component`) |
| `color` | `string` | 基本テキスト色(全要素に適用) |
| `headings` | `object` | 見出しスタイル(h1〜h4) |
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/content/docs/ja/markdown-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ transition: slide-from-right
| 設定 | 説明 |
|------|------|
| `figdeck` | VSCode 拡張機能の機能を有効化(`true`/`false`) |
| `cover` | 1枚目を表紙として扱う(`true`/`false`、デフォルト: `true`) |
| `background` | 統合背景設定:色、グラデーション、画像、テンプレート、Figma コンポーネント |
| `color` | ベーステキスト色 |
| `headings` | 見出しスタイル(h1, h2, h3, h4) |
Expand Down
32 changes: 32 additions & 0 deletions packages/plugin/src/code.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,38 @@ beforeEach(() => {
});

describe("validateAndSanitizeSlides", () => {
it("preserves cover flag when boolean", async () => {
const { validateAndSanitizeSlides } = await import("./code");

const result = validateAndSanitizeSlides([
{
cover: true,
blocks: [{ kind: "paragraph", text: "Cover" }],
},
]);

expect(result.valid).toBe(true);
if (!result.valid) return;

expect(result.slides[0].cover).toBe(true);
});

it("drops cover flag when not boolean", async () => {
const { validateAndSanitizeSlides } = await import("./code");

const result = validateAndSanitizeSlides([
{
cover: "true",
blocks: [{ kind: "paragraph", text: "Not cover" }],
},
]);

expect(result.valid).toBe(true);
if (!result.valid) return;

expect(result.slides[0].cover).toBeUndefined();
});

it("preserves BulletItem hierarchy while sanitizing text", async () => {
const { validateAndSanitizeSlides } = await import("./code");

Expand Down
Loading