An open API service indexing awesome lists of open source software.

https://github.com/ikuradon/nos2md

Nostr kind:1 events to Markdown converter
https://github.com/ikuradon/nos2md

deno markdown nostr obsidian

Last synced: 24 days ago
JSON representation

Nostr kind:1 events to Markdown converter

Awesome Lists containing this project

README

          

# nos2md

Fetch your Nostr text notes (kind:1) and export them as daily Markdown files — perfect for Obsidian.

Nostrのテキストノート(kind:1)を取得して、日単位のMarkdownファイルに出力するツールです。Obsidianとの連携に最適。

## Features / 機能

- 📡 Fetch kind:1 events from multiple relays / 複数リレーからkind:1イベントを取得
- 📅 Group notes by day / 日単位でノートをグループ化
- 🎨 Customizable output via [Eta](https://eta.js.org/) templates / Etaテンプレートで出力を自由にカスタマイズ
- 🔗 Auto-generated nevent links / neventリンクを自動生成
- ⚙️ All settings in a single config file / 設定ファイル1つで管理

## Requirements / 必要なもの

- [Deno](https://deno.com/) v2+

## Quick Start / クイックスタート

### 1. Clone & configure / クローン&設定

```bash
git clone https://github.com/yourname/nos2md.git
cd nos2md
```

Copy the sample config and edit it:

サンプル設定をコピーして編集してください:

```bash
cp config.sample.json config.json
```

Edit `config.json` with your settings:

`config.json` を編集してください:

```json
{
"relays": [
"wss://relay.damus.io",
"wss://nos.lol",
"wss://yabu.me"
],
"npub": "npub1your...pubkey",
"outputDir": "./output",
"timezone": "Asia/Tokyo",
"daysBack": 7,
"templateDir": "./templates",
"templateFile": "daily",
"linkPrefix": "https://njump.me/"
}
```

### 2. Run / 実行

```bash
deno task start
```

Or with a custom config path / 設定ファイルのパスを指定する場合:

```bash
deno task start -- --config /path/to/config.json
```

### 3. Output / 出力

Daily Markdown files will be generated in your `outputDir`:

`outputDir` に日単位のMarkdownファイルが生成されます:

```
output/
├── 2026-01-29.md
├── 2026-01-30.md
├── 2026-01-31.md
├── 2026-02-01.md
├── 2026-02-02.md
├── 2026-02-03.md
└── 2026-02-04.md
```

## Config Reference / 設定リファレンス

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `relays` | `string[]` | *(required)* | Relay URLs / リレーURL一覧 |
| `npub` | `string` | *(required)* | Your npub / 取得対象のnpub |
| `outputDir` | `string` | `"./output"` | Output directory (supports `{{YYYY}}`, `{{MM}}`, `{{DD}}`, `{{date}}` placeholders) / 出力先ディレクトリ(テンプレート変数対応) |
| `timezone` | `string` | `"Asia/Tokyo"` | Timezone for date grouping / 日付グループ化のタイムゾーン |
| `daysBack` | `number` | `7` | Number of days to fetch / 取得する日数 |
| `templateDir` | `string` | `"./templates"` | Template directory / テンプレートディレクトリ |
| `templateFile` | `string` | `"daily"` | Template file name (without `.eta`) / テンプレートファイル名(`.eta`なし) |
| `linkPrefix` | `string` | `"https://njump.me/"` | URL prefix for note links / ノートリンクのURLプレフィックス |

## Templates / テンプレート

nos2md uses [Eta](https://eta.js.org/) as its template engine. Edit `templates/daily.eta` to customize the output.

nos2mdは [Eta](https://eta.js.org/) テンプレートエンジンを使用しています。`templates/daily.eta` を編集して出力をカスタマイズできます。

### Available Variables / 使用可能な変数

**Top level / トップレベル:**

| Variable | Description |
|----------|-------------|
| `it.date` | Date string (YYYY-MM-DD) / 日付文字列 |
| `it.events` | Array of events / イベント配列 |
| `it.npub` | Configured npub / 設定されたnpub |
| `it.timezone` | Configured timezone / 設定されたタイムゾーン |

**Each event (`ev`) / 各イベント:**

| Variable | Description |
|----------|-------------|
| `ev.time` | Formatted time (HH:MM) / フォーマット済み時刻 |
| `ev.content` | Note content / ノート本文 |
| `ev.noteId` | note1... encoded ID / note1... エンコードID |
| `ev.nevent` | nevent encoded ID (with relay hints) / neventエンコードID(リレーヒント付き) |
| `ev.link` | Full link (linkPrefix + nevent) / 完全なリンク |
| `ev.id` | Raw hex event ID / 生のhexイベントID |
| `ev.pubkey` | Author's hex pubkey / 投稿者のhex公開鍵 |
| `ev.created_at` | Unix timestamp / Unixタイムスタンプ |
| `ev.tags` | Event tags array / イベントタグ配列 |

### Example Template / テンプレート例

```eta
# Nostr Notes - <%= it.date %>

> <%= it.events.length %> notes

---

<% for (const ev of it.events) { %>
### <%= ev.time %>

<%= ev.content %>

> [<%= ev.nevent.slice(0, 24) %>...](<%= ev.link %>)

---

<% } %>
```

## Use with Obsidian / Obsidianで使う

Set `outputDir` to a folder inside your Obsidian vault. You can use template placeholders to match your Daily Notes folder structure:

`outputDir` にObsidian vaultのフォルダを指定してください。テンプレート変数を使ってDaily Notesのフォルダ構造に合わせられます:

```json
{
"outputDir": "/path/to/your/vault/Nostr/{{YYYY}}/{{MM}}"
}
```

**Available placeholders / 使用可能なプレースホルダー:**

| Placeholder | Example | Description |
|-------------|---------|-------------|
| `{{YYYY}}` | `2026` | Year / 年 |
| `{{MM}}` | `02` | Month (zero-padded) / 月(ゼロ埋め) |
| `{{DD}}` | `04` | Day (zero-padded) / 日(ゼロ埋め) |
| `{{date}}` | `2026-02-04` | Full date / 日付 |

**Example structures / フォルダ構造の例:**

```
# Monthly folders / 月単位
"outputDir": "./vault/Nostr/{{YYYY}}/{{MM}}"
→ vault/Nostr/2026/02/2026-02-04.md

# Year-Month folders / 年月フォルダ
"outputDir": "./vault/Nostr/{{YYYY}}-{{MM}}"
→ vault/Nostr/2026-02/2026-02-04.md

# Flat / フラット
"outputDir": "./vault/Nostr"
→ vault/Nostr/2026-02-04.md
```

The daily files will appear as notes in Obsidian. You can also use Obsidian's Daily Notes plugin alongside these files.

日単位のファイルがObsidian上にノートとして表示されます。ObsidianのDaily Notesプラグインと組み合わせて使うこともできます。

## License

MIT