Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdownのファイル位置とHTMLのファイル位置が大きくズレている #129

Open
ncaq opened this issue Feb 13, 2023 · 2 comments
Labels
Priority: Medium Type: Breaking Change Includes breaking changes Type: Bug Bug or Bug fixes Type: Documentation Documentation only changes Type: Maintenance Repository Maintenance Type: Refactoring A code change that neither fixes a bug nor adds a feature

Comments

@ncaq
Copy link
Owner

ncaq commented Feb 13, 2023

例えばentry/2023-02-09-17-21-08.mdは、
entryを抜いて、
ファイルの-/に変更してそのディレクトリを作って、
index.htmlにして置いています。

index.htmlにすること自体はむしろ良いのですが、
-/にしていることが問題で、
これにより出力するディレクトリ階層が大きくズレてしまうため、
内部リンクが効かなくなってしまっています。

単なる内部リンクが効かないだけなら絶対リンクを貼れば良いだけです。

しかし画像などへのリンクが効かなくなることが問題で、
現在/asset/ディレクトリに全部置いてそれを絶対参照していますが、
これはwebサイトして単体でホスティングした時のみ認識可能なトップレベルディレクトリです。
これを行っているとGitHubにはリンクは認識されないからGitHub上でのレンダリングは行われません。
ファイル名補完も効きません。
一部の記事だけを取り出してPDF化するのも困難になります。
ライブプレビューはまあCSSとか面倒だし良いけれど。
サイトをサブディレクトリとして分離するのも不可能です。
将来的にHakyll以外に移ることも難しいかもしれません。

また/asset/ディレクトリにある画像名が被ると問題なので、
スクリーンショットなどの元から日時があるもの以外にはprefixとして余計な日付をファイル名の前につける必要が出てきます。
一つ一つの記事は独立しているべきなのに、
それぞれを区別するのは煩雑な問題です。

解決方法

まずentryは消してしまい年をトップレベルに置きます。
そして各ファイルの-/に変換して、
HTMLにした時の階層ギャップを無くします。
ファイル名はindex.mdとして、
自然にindex.htmlとなるようにします。

これで一段落です。

そして/asset/にあるファイルですが、
これは雑にリンクを取り出す雑スクリプトを書いて、
それによってファイルを移動させます。
Pandocで画像リンクを読み込んでファイルムーブしてやれば良いですね。

ファイルの名前の方ですが、
プレフィックス付きのファイルは37個しか無いようなので、
年で検索すれば出てくるのでこれぐらいならスクリプト書くより手作業の方が誤爆危険性も少ない可能性がありますね。
Pandocで走査して書き換える手もありますが、
一回ASTにしたMarkdownの画像リンク名を書き換えてMarkdownに戻しても元のデータが残ってないような気がしますね。
ファイル名変える所だけPandocを利用したプログラムにして、
リンク名を書き換えるのはEmacsを利用した正規表現にするべきでしょうか。

@ncaq ncaq added Type: Bug Bug or Bug fixes Priority: Medium Type: Refactoring A code change that neither fixes a bug nor adds a feature Type: Breaking Change Includes breaking changes Type: Maintenance Repository Maintenance Estimate: 8 labels Feb 13, 2023
@ncaq
Copy link
Owner Author

ncaq commented Feb 13, 2023

また、GitHubに位置するファイルを推定しづらいので、PRを送ってもらう仕組みを構築するのも難しいでしょう。

@ncaq ncaq added this to @ncaq TODO Feb 13, 2023
@ncaq ncaq moved this from Todo to priority in @ncaq TODO Feb 13, 2023
@ncaq ncaq moved this from priority to Todo in @ncaq TODO Feb 13, 2023
@ncaq ncaq moved this from Todo to Later in @ncaq TODO Feb 13, 2023
@ncaq
Copy link
Owner Author

ncaq commented Feb 13, 2023

fix: assetの移動を忘れていた · ncaq/www.ncaq.net@f8dd3e0
でやらかしたように、internal checkをかけても内部リンクになってくれないため気がつけないのも欠点か。

@ncaq ncaq added the Type: Documentation Documentation only changes label Feb 17, 2023
@ncaq ncaq removed the Estimate: 32 label Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium Type: Breaking Change Includes breaking changes Type: Bug Bug or Bug fixes Type: Documentation Documentation only changes Type: Maintenance Repository Maintenance Type: Refactoring A code change that neither fixes a bug nor adds a feature
Projects
Status: TODO
Development

No branches or pull requests

1 participant