
  <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
      <title>調和と変革</title>
      <link>https://reiji990.blog/blog</link>
      <description>本とアニメと音楽について</description>
      <language>ja</language>
      <managingEditor>reiji990.mail@gmail.com (reiji990)</managingEditor>
      <webMaster>reiji990.mail@gmail.com (reiji990)</webMaster>
      <lastBuildDate>Mon, 09 Sep 2024 00:00:00 GMT</lastBuildDate>
      <atom:link href="https://reiji990.blog/tags/技術/feed.xml" rel="self" type="application/rss+xml"/>
      
  <item>
    <guid>https://reiji990.blog/blog/new-features-202409</guid>
    <title>ブログに最近追加した機能など(202409)</title>
    <link>https://reiji990.blog/blog/new-features-202409</link>
    <description>Next.jsアプリへMermaid.js、Chart.jsの追加</description>
    <pubDate>Mon, 09 Sep 2024 00:00:00 GMT</pubDate>
    <author>reiji990.mail@gmail.com (reiji990)</author>
    <category>技術</category>
    <content:encoded><![CDATA[<p>Next.jsアプリへMermaid.js、Chart.jsを追加した。</p>
<h2>コンポーネント</h2>
<p><a href="https://github.com/reiji990/blog/blob/main/components/DonutChart.tsx">DonutChart.tsx</a></p>
<p><a href="https://github.com/reiji990/blog/blob/main/components/LineChart.tsx">LineChart.tsx</a></p>
<p><a href="https://github.com/reiji990/blog/blob/main/components/Mermaid.tsx">Mermaid.tsx</a></p>
<h2>実践例</h2>
<h3>Mermaid.js</h3>
<ul>
    <details close>
        <summary>コード</summary>
<pre><code>export const sequenceDiagram = `
  sequenceDiagram title 平日の為の作り置き
  participant m as まな板
  participant p as フライパン
  participant c as 容器
note over m,c: 開始
note over m: ニンジンを切る
note over p: 油を入れる
m-)p: 食材を入れる
note over p: 中火
note over m: オクラを切る
note over m: アスパラガスを切る
note over m: ナスを切る
note over m: エリンギを切る
note over p: 火が通っていることを確認
m-)p: 食材を入れる
note over p: 塩、胡椒、タイム、ワイン、ローレルを入れる
note over p: 沸騰後、弱火
note over p: 10分煮込む
note over p: 火が通っていることを確認
p-)c: 容器へ移す
note over m: 鶏胸肉を切る
m-)p: 食材を入れる
note over p: 塩、胡椒、タイム、ケーパー、黒オリーブを入れる
note over p: 15分煮込む
note over p: 火が通っていることを確認
note over p: 火を消す
p-)c: 容器へ移す
note over m, p: 洗う
note over c: 常温まで冷えたことを確認
note over c: 冷蔵庫へ入れる
note over m,c: 終了
`

&#x3C;Mermaid chart={sequenceDiagram} />
</code></pre>
<pre><code>&#x3C;/details>
</code></pre>
</ul>
<p>export const sequenceDiagram = <code>  sequenceDiagram title 平日の為の作り置き   participant m as まな板   participant p as フライパン   participant c as 容器 note over m,c: 開始 note over m: ニンジンを切る note over p: 油を入れる m-)p: 食材を入れる note over p: 中火 note over m: オクラを切る note over m: アスパラガスを切る note over m: ナスを切る note over m: エリンギを切る note over p: 火が通っていることを確認 m-)p: 食材を入れる note over p: 塩、胡椒、タイム、ワイン、ローレルを入れる note over p: 沸騰後、弱火 note over p: 10分煮込む note over p: 火が通っていることを確認 p-)c: 容器へ移す note over m: 鶏胸肉を切る m-)p: 食材を入れる note over p: 塩、胡椒、タイム、ケーパー、黒オリーブを入れる note over p: 15分煮込む note over p: 火が通っていることを確認 note over p: 火を消す p-)c: 容器へ移す note over m, p: 洗う note over c: 常温まで冷えたことを確認 note over c: 冷蔵庫へ入れる note over m,c: 終了</code></p>
<Mermaid chart={sequenceDiagram} />
<ul>
    <details close>
        <summary>コード</summary>
<pre><code>export const pie = `
pie title 平日夜の食費内訳
    "お米" : 54.675
    "鶏肉" : 93.312
    "野菜" : 149.688
    "その他" : 36.72
`

&#x3C;Mermaid chart={pie} />
</code></pre>
<pre><code>&#x3C;/details>
</code></pre>
</ul>
<p>export const pie = <code>pie title 平日夜の食費内訳     "お米" : 54.675     "肉" : 93.312     "野菜" : 149.688     "その他" : 36.72</code></p>
<Mermaid chart={pie} />
<h3>Chart.js</h3>
<ul>
    <details close>
        <summary>コード</summary>
<pre><code>export const data = {
labels: ['お米', '肉', '野菜', 'その他'],
      datasets: [
        {
          label: 'Sales Distribution',
          data: [54.675, 93.312, 149.688, 36.72],
          backgroundColor: [
            'rgba(255, 99, 132, 0.2)',
            'rgba(54, 162, 235, 0.2)',
            'rgba(255, 206, 86, 0.2)',
            'rgba(75, 192, 192, 0.2)',
          ],
          borderColor: [
            'rgba(255, 99, 132, 1)',
            'rgba(54, 162, 235, 1)',
            'rgba(255, 206, 86, 1)',
            'rgba(75, 192, 192, 1)',
          ],
      borderWidth: 1,
    },
  ],
}

export const options = {
    responsive: true,
    plugins: {
      legend: {
        position: 'top',
      },
      title: {
        display: true,
        text: '平日夜の食費内訳',
      },
    },
  }

&#x3C;DonutChart data={data} options={options} />
</code></pre>
<pre><code>&#x3C;/details>
</code></pre>
</ul>
<p>export const data = {
labels: ['お米', '鶏肉', '野菜', 'その他'],
datasets: [
{
label: 'Sales Distribution',
data: [54.675, 93.312, 149.688, 36.72],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
],
borderWidth: 1,
},
],
}</p>
<p>export const options = {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: '平日夜の食費内訳',
},
},
}</p>
<DonutChart data={data} options={options} />
<ul>
    <details close>
        <summary>コード</summary>
<pre><code>export const data1 = {
  labels: ['2024/01', '2024/02', '2024/03', '2024/04', '2024/05', '2024/06', '2024/07', '2024/08'],
  datasets: [
    {
      label: 'Post数',
      data: [3, 4, 1, 2, 3, 3, 2, 4],
      fill: false,
      backgroundColor: 'rgba(75, 192, 192, 0.2)',
      borderColor: 'rgba(75, 192, 192, 1)',
      tension: 0.1,
    },
  ],
}

export const options1 = {
  responsive: true,
  plugins: {
    legend: {
      position: 'top',
    },
    title: {
      display: true,
      text: '映像作品鑑賞報告Post数',
    },
  },
  scales: {
    y: {
      beginAtZero: true,
    },
  },
}

&#x3C;LineChart data={data1} options={options1} />
</code></pre>
<pre><code>&#x3C;/details>
</code></pre>
</ul>
<p>export const data1 = {
labels: ['2024/01', '2024/02', '2024/03', '2024/04', '2024/05', '2024/06', '2024/07', '2024/08'],
datasets: [
{
label: 'Post数',
data: [3, 4, 1, 2, 3, 3, 2, 4],
fill: false,
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
tension: 0.1,
},
],
}</p>
<p>export const options1 = {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: '映像作品鑑賞報告Post数',
},
},
scales: {
y: {
beginAtZero: true,
},
},
}</p>
<LineChart data={data1} options={options1} />
<p>mermaid.jsは書き方が良くないのか、docker上での表示がうまくいかないため何度もデプロイして表示を確かめていた。
dockerの立ち上げ自体にも時間がかかるようになったので、mermaid.jsに関しては使わなければ機能を消すかも。</p>]]></content:encoded>
  </item>

  <item>
    <guid>https://reiji990.blog/blog/mac-setup-howto</guid>
    <title>Macセットアップ手順</title>
    <link>https://reiji990.blog/blog/mac-setup-howto</link>
    <description>先月Macを新調した。 Macは2021年にMacbook Airを購入してから3機目で、移行手順が確立できてきたのでメモを放流する。というか、移行手順をネット上で公開してコマンドもコピペできるようにしておくというのが一番楽な方法だった。 この記事では更新後の初動対応に絞り、アプ…</description>
    <pubDate>Mon, 12 Feb 2024 00:00:00 GMT</pubDate>
    <author>reiji990.mail@gmail.com (reiji990)</author>
    <category>技術</category>
    <content:encoded><![CDATA[<p>先月Macを新調した。</p>
<p>Macは2021年にMacbook Airを購入してから3機目で、移行手順が確立できてきたのでメモを放流する。というか、移行手順をネット上で公開してコマンドもコピペできるようにしておくというのが一番楽な方法だった。</p>
<p>この記事では更新後の初動対応に絞り、アプリ、パッケージのインストール、キーボード、トラックボールのカスタマイズ、Safari、Alfredの設定を最速で済ませることを目指す。</p>
<TOCInline toc={props.toc} asDisclosure />
<h2>アプリ、パッケージのインストール</h2>
<p>「Homebrewあれ」</p>
<pre><code class="language-:Terminal.app">/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
</code></pre>
<p>インストール後の<ruby>Next steps<rt>PATHへの追加</rt></ruby>も忘れずに。</p>
<br />
<p>可及的速やかに<a href="https://www.warp.dev">Warp</a>を導入し、以降はこれを使用する。
Karabiner-Elementsは次項で使用するためこれも優先的にインストールする。</p>
<pre><code class="language-:Terminal.app">brew install --cask warp
brew install --cask Karabiner-Elements
</code></pre>
<p>以下コマンドをコピペしインストール開始。
<a href="https://github.com/Homebrew/homebrew-bundle">Homebrew Bundle</a>も考えたが、この記事からコマンドをコピペした方が圧倒的に早いのだった。
コマンドは<code>brew bundle dump</code>で作成したBrewfileの行頭に"brew install"を付けて作成。<strong>更新作業直前に作り直すこと。</strong></p>
<p>時間がかかるのでコマンド実行後は待たずに次項の作業を実施して良い。</p>
<ul>
    <details close>
        <summary>コピペ用コマンド</summary>
<pre><code class="language-:Warp.app">brew install "ffmpeg"
brew install "git"
brew install "icu4c@76"
brew install "imagemagick"
brew install "mas"
brew install "node"
brew install "perl"
brew install "php"
brew install "python@3.12"
brew install --cask "adobe-acrobat-reader"
brew install --cask "alfred"
brew install --cask "alt-tab"
brew install --cask "chatgpt"
brew install --cask "discord"
brew install --cask "docker-desktop"
brew install --cask "drawio"
brew install --cask "firefox"
brew install --cask "github"
brew install --cask "google-chrome"
brew install --cask "google-drive"
brew install --cask "iina"
brew install --cask "iterm2"
brew install --cask "karabiner-elements"
brew install --cask "libreoffice"
brew install --cask "logi-options+"
brew install --cask "obs"
brew install --cask "pdf-expert"
brew install --cask "sublime-text"
brew install --cask "utm"
brew install --cask "visual-studio-code"
brew install --cask "vitalsource-bookshelf"
brew install --cask "vlc"
brew install --cask "vmware-fusion"
brew install --cask "wacom-tablet"
brew install --cask "warp"
brew install --cask "zed"
brew install --cask "zoom"
brew install --mas "AdGuard for Safari", id: 1440147259
brew install --mas "Colibri", id: 1178295426
brew install --mas "CotEditor", id: 1024640650
brew install --mas "CrystalFetch", id: 6454431289
brew install --mas "Dark Reader for Safari", id: 1438243180
brew install --mas "DaVinci Resolve", id: 571213070
brew install --mas "Developer", id: 640199958
brew install --mas "GarageBand", id: 682658836
brew install --mas "iMovie", id: 408981434
brew install --mas "Keepa - Price Tracker", id: 1533805339
brew install --mas "Keynote", id: 409183694
brew install --mas "Kindle", id: 302584613
brew install --mas "LINE", id: 539883307
brew install --mas "Macgo Blu-ray Player Pro", id: 1403952861
brew install --mas "Magnet", id: 441258766
brew install --mas "Numbers", id: 409203825
brew install --mas "Pages", id: 409201541
brew install --mas "PixelFinder", id: 1512540355
brew install --mas "Xcode", id: 497799835
brew install --mas "デスクトップ時計", id: 894760156
brew install --mas "辞書 by 物書堂", id: 1380563956
</code></pre>
<pre><code>&#x3C;/details>
</code></pre>
</ul>
<h2>キーボード、トラックボールの設定</h2>
<h3>トラックボール(Kensington Slimblade)</h3>
<p><a href="https://www.kensington.com/software/kensingtonworks/">KensingtonWorks.app</a>を手動インストール。</p>
<p>設定は画像を参照。
<strong>バック・フォワードはWebブラウザタブのものを使用すること。</strong></p>
<p><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/R/ReijiE/20240211/20240211170532.png" alt="KensingtonWorks設定画面"></p>
<h3>キーボード</h3>
<p>Karabiner-Elements.appの"complex modifications"に以下ルールを追加。</p>
<ul>
    <details close>
        <summary>コマンドキーを単体で押したときに、英数・かなキーを送信する。（左コマンドキーは英数、右コマンドキーはかな）(UTM実行中は無効化する)</summary>
<pre><code>{
    "description": "コマンドキーを単体で押したときに、英数・かなキーを送信する。（左コマンドキーは英数、右コマンドキーはかな）(UTM実行中は無効化する) (rev 3)",
    "manipulators": [
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^com\\.utmapp\\.UTM$"
                    ],
                    "file_paths": [
                        "/Applications/UTM.app/Contents/MacOS/UTM"
                    ],
                    "type": "frontmost_application_unless"
                }
            ],
            "from": {
                "key_code": "left_command",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "parameters": {
                "basic.to_if_held_down_threshold_milliseconds": 100
            },
            "to": [
                {
                    "key_code": "left_command",
                    "lazy": true
                }
            ],
            "to_if_alone": [
                {
                    "key_code": "japanese_eisuu"
                }
            ],
            "to_if_held_down": [
                {
                    "key_code": "left_command"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^com\\.utmapp\\.UTM$"
                    ],
                    "file_paths": [
                        "/Applications/UTM.app/Contents/MacOS/UTM"
                    ],
                    "type": "frontmost_application_unless"
                }
            ],
            "from": {
                "key_code": "right_command",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "parameters": {
                "basic.to_if_held_down_threshold_milliseconds": 100
            },
            "to": [
                {
                    "key_code": "right_command",
                    "lazy": true
                }
            ],
            "to_if_alone": [
                {
                    "key_code": "japanese_kana"
                }
            ],
            "to_if_held_down": [
                {
                    "key_code": "right_command"
                }
            ],
            "type": "basic"
        }
    ]
}
</code></pre>
<pre><code>&#x3C;/details>
</code></pre>
</ul>
<ul>
    <details close>
        <summary>シフトキーを単体で押したときに、alfredを実行する(UTM実行中は無効化する)</summary>
<pre><code>{
    "description": "シフトキーを単体で押したときに、alfredを実行する(UTM実行中は無効化する)",
    "manipulators": [
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^com\\.utmapp\\.UTM$"
                    ],
                    "file_paths": [
                        "/Applications/UTM.app/Contents/MacOS/UTM"
                    ],
                    "type": "frontmost_application_unless"
                }
            ],
            "from": {
                "key_code": "left_shift",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "parameters": {
                "basic.to_if_held_down_threshold_milliseconds": 100
            },
            "to": [
                {
                    "key_code": "left_shift",
                    "lazy": true
                }
            ],
            "to_if_alone": [
                {
                    "key_code": "spacebar",
                    "modifiers": [
                        "command"
                    ]
                }
            ],
            "to_if_held_down": [
                {
                    "key_code": "left_shift"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^com\\.utmapp\\.UTM$"
                    ],
                    "file_paths": [
                        "/Applications/UTM.app/Contents/MacOS/UTM"
                    ],
                    "type": "frontmost_application_unless"
                }
            ],
            "from": {
                "key_code": "right_shift",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "parameters": {
                "basic.to_if_held_down_threshold_milliseconds": 100
            },
            "to": [
                {
                    "key_code": "right_shift",
                    "lazy": true
                }
            ],
            "to_if_alone": [
                {
                    "key_code": "spacebar",
                    "modifiers": [
                        "command"
                    ]
                }
            ],
            "to_if_held_down": [
                {
                    "key_code": "right_shift"
                }
            ],
            "type": "basic"
        }
    ]
}
</code></pre>
<pre><code>&#x3C;/details>
</code></pre>
</ul>
<h2>アプリ設定</h2>
<h3>Safariのローカル拡張機能追加</h3>
<p>Xcodeで拡張機能のプロジェクトファイルを実行する。
(下２つは<a href="https://developer.apple.com/jp/news/?id=qiz0arxc">Google Chromeの拡張機能を変換</a>したもの。プライベートリポジトリで管理している)</p>
<ul>
<li><a href="https://github.com/reiji990/Safari-Auto-Copy-extension">Auto Copy</a></li>
<li><a href="https://github.com/reiji990/Life/tree/main/code/AutoScroll">AutoScroll</a></li>
<li><a href="https://github.com/reiji990/Life/tree/main/code/TWP%20-%20Translate%20Web%20Pages%202">TWP</a></li>
</ul>
<h3>Alfredの設定</h3>
<ul>
<li>Powerpackの認証</li>
<li>Hotkeyを⌘+Spaceに</li>
<li>検索範囲の設定</li>
<li>Workflowの追加
<ul>
<li>Search Apple Music</li>
<li>Search Notes</li>
<li>Shortcuts</li>
</ul>
</li>
<li>Web searchの追加</li>
<li>デフォルト検索候補の設定(Default ResultsのSetup fallback resultsより)</li>
</ul>
<h3>その他、初日に済ませないと不便すぎて終わるタイプのアプリ設定作業</h3>
<ul>
<li>Dictionaries.appの購入済み辞書のインストール</li>
<li>Music.appのデバイス承認</li>
<li>Message.appのサインイン</li>
<li>Reminders.appのサインイン</li>
<li>Mail.appのサインイン</li>
<li>Calendar.appのサインイン</li>
</ul>
<h2>コマンド、スクリプトでの設定</h2>
<ul>
<li><a href="https://qiita.com/TsukasaHasegawa/items/fa8e783a556dc1a08f51">【Mac】隠しファイル・隠しフォルダを表示する方法</a></li>
<li><a href="https://zenn.dev/nemolize/articles/a6ee70078051e3">macOS Sonomaでテキストカーソル横にIMEモードが出るようになった</a></li>
<li><a href="https://zenn.dev/masaaania/articles/fabfe969f4f0e3">macのスクリーンショット体験を改善するためにやったこと。</a></li>
</ul>
<pre><code class="language-:Warp.app">defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
sudo mkdir -p /Library/Preferences/FeatureFlags/Domain
sudo /usr/libexec/PlistBuddy -c "Add 'redesigned_text_cursor:Enabled' bool false" /Library/Preferences/FeatureFlags/Domain/UIKit.plist
defaults write com.apple.screencapture name ""
</code></pre>
<pre><code class="language-:Automator.app">on run {input, parameters}
	set filePath to item 1 of input as text
	set the clipboard to (read (filePath as alias) as TIFF picture)
end run
</code></pre>]]></content:encoded>
  </item>

  <item>
    <guid>https://reiji990.blog/blog/new-features-202309</guid>
    <title>ブログに最近追加した機能など(202309)</title>
    <link>https://reiji990.blog/blog/new-features-202309</link>
    <description>新テンプレートへの移行, コンテンツ埋め込み, サブタイトル・最終更新日追加</description>
    <pubDate>Sun, 10 Sep 2023 00:00:00 GMT</pubDate>
    <author>reiji990.mail@gmail.com (reiji990)</author>
    <category>技術</category>
    <content:encoded><![CDATA[<p>最近追加した機能についてのメモ。</p>
<TOCInline toc={props.toc} asDisclosure />
<br />
<h2>新テンプレートへの移行</h2>
<p><a href="https://tailwind-nextjs-starter-blog.vercel.app/blog/release-of-tailwind-nextjs-starter-blog-v2.0">https://tailwind-nextjs-starter-blog.vercel.app/blog/release-of-tailwind-nextjs-starter-blog-v2.0</a></p>
<p>移行するにあたっては、推奨されている通り新テンプレートをコピーし、これまでの編集履歴を反映し直して対応した。
記法に変更があったり、エラーも色々発生したが、ググれば解決できるレベルなので説明は省略。</p>
<p>検索コンポーネント(Algolia)について、現在使用しているライブラリ(<a href="https://github.com/timlrx/pliny">plinyリポジトリ内のもの</a>)が日本語に対応していないので、検索ボタンだけ削除している。早晩対応する。</p>
<h2>コンテンツ埋め込み</h2>
<p>まずはじめに、CSP(Content Security Policy)を設定。</p>
<pre><code class="language-diff-js:next.config.js"> const ContentSecurityPolicy = `
   default-src 'self';
-  script-src 'self' 'unsafe-eval' 'unsafe-inline' giscus.app analytics.umami.is;
-  style-src 'self' 'unsafe-inline';
+  script-src 'self' 'unsafe-eval' 'unsafe-inline' 'giscus.app' 'analytics.umami.is' 'https://twitter.com' 'https://*.twitter.com' 'https://syndication.twitter.com' 'https://www.nicovideo.jp' 'https://open.spotify.com';
+  style-src 'self' 'unsafe-inline' 'https://www.youtube.com' 'https://twitter.com' 'https://*.twitter.com' 'https://syndication.twitter.com' 'https://www.nicovideo.jp' 'https://open.spotify.com';
   img-src * blob: data:;
   media-src *.s3.amazonaws.com;
   connect-src *;
   font-src 'self';
-  frame-src giscus.app
+  frame-src giscus.app https://www.youtube.com https://twitter.com https://*.twitter.com https://syndication.twitter.com https://www.nicovideo.jp https://ext.nicovideo.jp https://open.spotify.com;
+  child-src https://www.youtube.com https://twitter.com https://*.twitter.com https://syndication.twitter.com https://www.nicovideo.jp https://ext.nicovideo.jp https://open.spotify.com;
 `
</code></pre>
<br />
<h3>𝕏</h3>
<p><a href="https://github.com/vercel/react-tweet">https://github.com/vercel/react-tweet</a></p>
<p>Vercelが7月に公開した埋め込み用ライブラリ。<a href="https://github.com/vercel/react-tweet/issues/137#issuecomment-1720148509">その後まもなく𝕏からのアクセス拒否(?)で使えなくなっていたが、9/15に復活した模様。</a></p>
<pre><code>&#x3C;Tweet id="1702605663770440074"/>
</code></pre>
<Tweet id="1702605663770440074" />
<h3>ニコニコ動画</h3>
<p>ニコニコ動画公式の埋め込みコードはscriptタグを使用しているが、<strong>Next.jsではscriptタグを使えない。</strong></p>
<p><a href="https://zenn.dev/hatsumihayashi/articles/3834902cf5ac4e">https://zenn.dev/hatsumihayashi/articles/3834902cf5ac4e</a></p>
<p>対応策として、今回は以下記事の方法2を採用。</p>
<p><a href="https://qiita.com/fanta_cps/items/13e0819e0c1db111186c">https://qiita.com/fanta_cps/items/13e0819e0c1db111186c</a></p>
<ul>
<li>
<p><a href="https://github.com/reiji990/blog/blob/main/components/Niconico.tsx">Niconico.tsx</a></p>
<p>作成したコンポーネント。頭の<code>'use client'</code>とか、MessageEventの型とか、このブログで使用するにあたり少し変更がある。</p>
</li>
</ul>
<pre><code>&#x3C;NicovideoPlayer id="so32488462" />
</code></pre>
<NicovideoPlayer id="so32488462" />
<h3>YouTube</h3>
<p>YouTubeは動画ページから埋め込みコードを取得して貼るだけでも良いが、フルスクリーンにできないことと、幅固定になってしまいスマホで表示した時に表示が崩れる問題がある。
ニコニコ動画埋め込み用のコンポーネントをURLだけ変更してYouTubeに適用する。</p>
<ul>
<li><a href="https://github.com/reiji990/blog/blob/main/components/Youtube.tsx">Youtube.tsx</a></li>
</ul>
<pre><code>&#x3C;YoutubevideoPlayer id="1-o7fmQqSNg" />
</code></pre>
<YoutubevideoPlayer id="1-o7fmQqSNg" />
<h3>Spotify</h3>
<p>Spotifyも公式の埋め込みコードはそのままでは使えないのでコンポーネントを作成した。</p>
<ul>
<li><a href="https://github.com/reiji990/blog/blob/main/components/Spotify.tsx">Spotify.tsx</a></li>
</ul>
<pre><code>&#x3C;SpotifyPlayer id="7rNb5UJ9IhpTEw6Yl99FqT" />
</code></pre>
<SpotifyPlayer id="7rNb5UJ9IhpTEw6Yl99FqT" />
<br />
<h2>サブタイトル、最終更新日追加</h2>
<pre><code class="language-diff">  ---
  title: 記事タイトル
+ subtitle: サブタイトル
  tags: ['test']
  date: '1-1-1'
+ lastmod: '1-1-2'
  draft: true
  summary: '概要'
  ---
</code></pre>
<div className="my-1 w-full overflow-hidden px-2 xl:my-1 xl:w-1/2 xl:px-2">
  <img
    art="サブタイトル、最終更新日"
    src="https://reiji990.blog/static/images/new-features-202309/subtitle,lastmod.png"
  />
</div>
<ul>
<li>
<p>変更箇所</p>
<p>他にも変更箇所はあるがコミットが散逸しているので実装初めのマージコミットだけ貼っておく。</p>
<ul>
<li>
<p><a href="https://github.com/reiji990/blog/commit/e880bd5b27626bef73ed27bf3f67e6da57fcdc0c">subtitle</a></p>
</li>
<li>
<p><a href="https://github.com/reiji990/blog/commit/607f33351d80b9490c4c53e0bbe4d4eacfe33a27">lastmod</a></p>
</li>
</ul>
</li>
</ul>]]></content:encoded>
  </item>

  <item>
    <guid>https://reiji990.blog/blog/how-to-create-a-blog</guid>
    <title>本ブログの作成方法</title>
    <link>https://reiji990.blog/blog/how-to-create-a-blog</link>
    <description>このブログの作成方法のメモを残します。 作業環境 種別 詳細 OS MacOS 13.4 CPU Apple M1 Windows の場合、インストール時のコマンドが少し異なります。そちらも併記しています。 使用サービス 全て無料で使用できることを前提に選定しています。 種別 詳…</description>
    <pubDate>Sun, 28 May 2023 00:00:00 GMT</pubDate>
    <author>reiji990.mail@gmail.com (reiji990)</author>
    <category>技術</category>
    <content:encoded><![CDATA[<p>このブログの作成方法のメモを残します。</p>
<h2>作業環境</h2>
<table>
<thead>
<tr>
<th>種別</th>
<th>詳細</th>
</tr>
</thead>
<tbody>
<tr>
<td>OS</td>
<td>MacOS 13.4</td>
</tr>
<tr>
<td>CPU</td>
<td>Apple M1</td>
</tr>
</tbody>
</table>
<p>Windows の場合、インストール時のコマンドが少し異なります。そちらも併記しています。</p>
<h2>使用サービス</h2>
<p>全て無料で使用できることを前提に選定しています。</p>
<table>
<thead>
<tr>
<th>種別</th>
<th>詳細</th>
</tr>
</thead>
<tbody>
<tr>
<td>コード管理</td>
<td>GitHub</td>
</tr>
<tr>
<td>開発環境</td>
<td>Docker</td>
</tr>
<tr>
<td>ホスティング</td>
<td>Vercel</td>
</tr>
<tr>
<td>ブログ機能</td>
<td>Next.js</td>
</tr>
<tr>
<td>テンプレート</td>
<td><a href="https://github.com/timlrx/tailwind-nextjs-starter-blog">timlrx/tailwind-nextjs-starter-blog</a></td>
</tr>
</tbody>
</table>
<h2>参考</h2>
<p><a href="https://zenn.dev/miketako3/articles/9b2b1a9ec13901">https://zenn.dev/miketako3/articles/9b2b1a9ec13901</a></p>
<p><a href="https://next-blog-starter.vercel.app/">Next.js のデモページ</a>と同じ内容を実装できれば良い場合は、リンク先の記事の手段の方が良いです。理由は以下になります。</p>
<ul>
<li>多くの人が Next.js デモページを使用してブログを作成しているため、後からデザイン変更したい場合に情報を見つけ易い</li>
<li>ホスティング先に Firebase を採用しており、商用利用が可能</li>
</ul>
<p>ただ、Next.js のテンプレートはシンプル過ぎて、デザインをはじめから作る必要があるため、今回はより完成度の高いテンプレートを使用します。</p>
<h2>事前準備</h2>
<ul>
<li>Vercel のアカウント作成</li>
<li>GitHub のアカウント作成</li>
<li>GitHub Desktop のインストール</li>
<li>Docker のインストール</li>
</ul>
<h2>手順</h2>
<p>Docker 上で開発する環境整備と、Vercel にデプロイするまでの手順になります。</p>
<h3>インストール</h3>
<p>cd をブログ用のフォルダを作成するディレクトリに移動し、下記コマンドを実行します。</p>
<p>各コマンド末尾の<code>blog</code>はディレクトリ内に新たに作成するフォルダ名となります。</p>
<pre><code>docker run --rm -it -v $PWD:/home/app -w /home/app node yarn create next-app --example https://github.com/timlrx/tailwind-nextjs-starter-blog blog
cd blog
</code></pre>
<p>Windows の場合はこちら(PowerShell で実行)</p>
<pre><code>docker run --rm -it -v ${PWD}:/home/app -w /home/app node yarn create next-app --example https://github.com/timlrx/tailwind-nextjs-starter-blog blog
cd blog
</code></pre>
<p>インストール終了後、localhost で確認してみます。</p>
<pre><code>docker run --rm -it -v $PWD:/home/app -w /home/app -p 3000:3000 node yarn dev
</code></pre>
<p>Windows の場合はこちら(PowerShell で実行)</p>
<pre><code>docker run --rm -it -v ${PWD}:/home/app -w /home/app -p 3000:3000 node yarn dev
</code></pre>
<p><a href="https://tailwind-nextjs-starter-blog.vercel.app">デモページ</a>と同じ内容が <a href="http://localhost:3000">http://localhost:3000</a> に表示されるはずです。</p>
<h3>Docker の設定</h3>
<p>続いて、Docker の設定です。必要なファイルを作成します。</p>
<pre><code>touch Dockerfile &#x26;&#x26; touch docker-compose.yml
</code></pre>
<p>作成されたファイルに以下をコピペ。</p>
<pre><code class="language-:Dockerfile">FROM node
</code></pre>
<pre><code class="language-yml:docker-compose.yml">version: '3'

services:
  app:
    build: .
    working_dir: /home/app
    ports:
      - "3000:3000"
    volumes:
      - .:/home/app
    tty: true
    stdin_open: true
    command: yarn dev
</code></pre>
<p>Docker の設定をビルドし、実行。</p>
<pre><code>docker compose build --no-cache
docker compose up
</code></pre>
<p>これで、今後は<code>docker compose up</code>を実行することで <a href="http://localhost:3000">http://localhost:3000</a> にデモページと同じ内容が表示されます。</p>
<h3>GitHub のリポジトリ作成</h3>
<p>作成した blog ディレクトリを GitHub リポジトリに追加します。</p>
<p>方法はいくつもありますが、一番簡単な方法は GitHub Desktop を使用することかなと思います。</p>
<p>Add Existing Repository から、ローカルパスに先ほどの blog ディレクトリを選択、リポジトリ名を決めて作成します。</p>
<p><img src="https://reiji990.blog/static/images/how-to-create-a-blog/GitHub-Desktop.png" alt="GitHub Desktop"></p>
<h3>Vercel の設定</h3>
<p><a href="https://vercel.com/dashboard">Vercel</a>のダッシュボード画面から Create Project を選択。先ほど作成した GitHub リポジトリを選択し、import、Deploy を選択。</p>
<p><img src="https://reiji990.blog/static/images/how-to-create-a-blog/Vercel.png" alt="Vercel"></p>
<p>これで、Vercel から提供されたドメインにデモページと同じ内容が表示されるはずです。</p>
<p>ブログデザインの変更や記事の執筆を終えた際は、GitHub の main ブランチに変更をコミットすれば変更内容が Vercel にデプロイされます。</p>
<hr>
<p>ブログの作成方法は以上となります。デザインの変更方法は Next.js の公式ドキュメント等をご参照の上で実施いただければと思います。</p>
<p>まだ私自身ブログのデザインや使用技術に満足したわけではなく、これからも変更を加えていきますので、その中で手間取った変更があれば記事にしようかと思います。</p>]]></content:encoded>
  </item>

    </channel>
  </rss>
