Skip to content

目次のプレビューができるように#331

Closed
cm-wada-yusuke wants to merge 8 commits into
canaryfrom
feat-preview-toc
Closed

目次のプレビューができるように#331
cm-wada-yusuke wants to merge 8 commits into
canaryfrom
feat-preview-toc

Conversation

@cm-wada-yusuke
Copy link
Copy Markdown
Member

📑 Summary

記事やチャプターに対して、目次のプレビューができるようにします。

refs zenn-dev/zenn-community#399

これの一環。まずはフラッグシップ的に zenn-cli で試します。

📋 Tasks

プルリクエストを作成いただく際、お手数ですが以下の内容についてご確認をお願いします。

  • 📖 Contribution Guide を読んだ
  • 👩‍💻 canary ブランチに対するプルリクエストである

@github-actions
Copy link
Copy Markdown
Contributor

Please add one of the following labels: fix, bugfix, enhancement, feature, chore, release

Comment thread package.json
],
"devDependencies": {
"lerna": "^4.0.0"
"lerna": "^5.4.3"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] ついでにバージョンアップ。どこかで バージョン5 にあげたい。

@@ -0,0 +1,256 @@
import { parseToc } from '../src/utils/toc';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] 目次のパースを zenn-markdown-html に移します。のでテストも追加。

@@ -0,0 +1,3 @@
import { parseToc } from './toc';

export { parseToc };
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[help] 結局、re-export したほうがいいのかどうなのかわかってないです。アドバイスおねがいします 🙏

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.js のライブラリなので、そのままでも大丈夫だと思います!
これが webpack や vite でバンドルされるようなライブラリなら "zenn-markdown-html/parseToc" のように一つの機能ごとにファイルにした方が Tree Shaking しやすいのでいいと思いますが、今回はそれは想定していないので大丈夫です。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほど、そうなのですね、ありがとうございます!

@@ -0,0 +1,47 @@
import * as cheerio from 'cheerio';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] 既存コードからのコピペです。

Copy link
Copy Markdown
Contributor

@uttk-dev uttk-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!!

@@ -0,0 +1,3 @@
import { parseToc } from './toc';

export { parseToc };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.js のライブラリなので、そのままでも大丈夫だと思います!
これが webpack や vite でバンドルされるようなライブラリなら "zenn-markdown-html/parseToc" のように一つの機能ごとにファイルにした方が Tree Shaking しやすいのでいいと思いますが、今回はそれは想定していないので大丈夫です。

@uttk-dev uttk-dev added the feature 機能追加・改善 label Aug 19, 2022
@cm-wada-yusuke
Copy link
Copy Markdown
Member Author

バージョンアップ作業がやや大掛かりになってきたため、別PRで対応します。

@cm-wada-yusuke cm-wada-yusuke deleted the feat-preview-toc branch August 23, 2022 02:37
@cm-dyoshikawa cm-dyoshikawa mentioned this pull request Sep 7, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 機能追加・改善

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants