diff --git a/ai/agents/import-notion-post.md b/ai/agents/import-notion-post.md new file mode 100644 index 00000000..7d026f60 --- /dev/null +++ b/ai/agents/import-notion-post.md @@ -0,0 +1,195 @@ +# import-notion-post + +Converts a Notion page into a production-ready blog post for `ajeetchaulagain.com`. + +--- + +## Prerequisites + +`NOTION_TOKEN` must be set in `.env.local`. The Notion page must be shared with the integration. + +--- + +## How to run + +Say **"execute with \"** to target a page directly, or **"execute"** to be prompted for a URL. + +--- + +## Execution steps + +1. **Fetch the draft** — read `NOTION_TOKEN` from `.env.local`, then call the Notion API to fetch the page content: + + ```bash + # Get page title + curl -s "https://api.notion.com/v1/pages/" \ + -H "Authorization: Bearer " \ + -H "Notion-Version: 2022-06-28" + + # Get page blocks (paginate with start_cursor if has_more=true) + curl -s "https://api.notion.com/v1/blocks//children?page_size=100" \ + -H "Authorization: Bearer " \ + -H "Notion-Version: 2022-06-28" + ``` + + Extract the page ID from the URL (last 32-char hex segment). Convert the block JSON to markdown yourself — handle `paragraph`, `heading_1/2/3`, `bulleted_list_item`, `numbered_list_item`, `code`, `callout`, `image`, and `quote` block types. + +2. **Read the reference** — read `src/posts/react-image-gallery.md` for the canonical frontmatter and formatting style. +3. **Convert** — apply all conversion rules below, in order. +4. **Proofread** — fix grammar and spelling silently (see [Proofreading](#proofreading)). +5. **Copy images** — move draft images to `src/images//` with descriptive names. +6. **Save** — write to `src/posts/.md`, overwriting any existing file. +7. **Verify** — run `yarn build` and confirm it passes. + +--- + +## Conversion rules + +### Frontmatter + +Remove all Notion metadata at the top (`Assign:`, `Status:`, `Deadline:`). + +Use the top-level `# H1` as the post title — put it in frontmatter, remove it from the body. + +```yaml +--- +title: '' +description: '' +date: '' +tags: ['tag1', 'tag2'] +thumbnail: + { src: ../images/thumbnails/.png, altText: '' } +author: 'Ajeet Chaulagain' +--- +``` + +> If no matching thumbnail exists, use `image-gallery-icon.png` as a placeholder. + +--- + +### Preserve the author's formatting + +Your job is **format conversion, not editing**. Copy the author's words exactly. + +| If the draft has… | Output… | +| ------------------------------------------------ | ------------------------------------------------ | +| A bullet list | A bullet list — never collapse to prose | +| A numbered list | A numbered list — never reorder | +| A paragraph followed by bullets | That exact structure | +| Two near-identical paragraphs | Both — they are intentional | +| A byte-for-byte duplicate paragraph | Only one — Notion export artifact | +| A duplicate intro sentence before unique content | Better-worded version + all content that follows | + +**The only words you may change:** + +- Broken Notion link syntax (see [Content cleanup](#content-cleanup)) +- Unfilled placeholders (``, `[Video will be attached here]`) +- Notion metadata lines + +--- + +### No imports + +Do **not** add import statements. All components (`InfoCallToAction`, etc.) are registered globally via the MDX provider. + +--- + +### Code blocks + +Notion exports everything as `tsx` or `jsx`. Reclassify each block: + +| Content | Language tag | +| ---------------------------- | ------------- | +| Shell commands | `bash` | +| TypeScript | `ts` | +| JSON | `json` | +| YAML | `yaml` | +| JSX / TSX | `jsx` / `tsx` | +| Output, file trees, diagrams | `bash:noCopy` | + +**Key files and configs** — add title and line highlight annotations: + +```` +```ts:title=src/lambda.ts {20-37}{numberLines:true} +```` + +**Directory structures and terminal output** — disable the copy button: + +```` +```bash:title=Directory_Structure&noCopy +```` + +Remove `$ ` prefixes from shell commands. + +--- + +### Callout / aside blocks + +Convert Notion `