-
Notifications
You must be signed in to change notification settings - Fork 26
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
下書きエントリーのファイル配置位置の変更 #128
Merged
下書きエントリーのファイル配置位置の変更 #128
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pull Request Test Coverage Report for Build 6755143085
💛 - Coveralls |
Songmu
force-pushed
the
draft
branch
4 times, most recently
from
October 30, 2023 15:04
5529a49
to
4529e53
Compare
Songmu
force-pushed
the
draft
branch
10 times, most recently
from
November 4, 2023 03:58
b231383
to
fd59b0d
Compare
Merged
This was referenced Nov 4, 2023
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
前提
blogsyncは公開URLのパスと対応した位置にエントリーファイル(Markdown)が保存される。(脱線だが、サブディレクトリ運用されている場合、サブディレクトリ含めて保存される ref. #127)
また、URLのパスは以下の2種類に分かれる。
執筆者が明示しない場合、自動付与が記事公開時におこなわれる。標準では
2001/02/03/150405
のような時刻ベースのフォーマットになる。他にも、はてなダイヤリーフォーマットや、タイトルを付与したフォーマットがあり、ブログ管理画面から切り替え設定できる。自動付与の場合「記事公開時に」と書いた通り、下書き時にはURLの付与は行われない。APIのレスポンスには仮のURLが返される。この仮のURLはAPIリクエスト時刻が基準になったものが返されるので、下書き更新時に毎回異なるものが返される。
つまり、CustomPathを指定してない下書きの場合、現状blogsyncで記事を更新したら、ファイル名やFrontMatter内のURLがコロコロ変わってしまう。例えば、
entry/2023/10/11/122334.md
がentry/2023/10/12/011223.md
とかに変更されてしまう。これは困る。変更内容
それに対する対応として以下のような変更を入れてようとしている。
entry/_draft/$entryID.md
に配置するentry/
配下に格納位置を作った_draft/
に配置するのは少し気持ち悪いという意見があるかもしれないが、妥協できるレベルではないかちなみに、はてなブログが自動付与したパスかどうかはを厳密に判定するのは難しく、正規表現でそれっぽいケースを判定している。
求める挙動
(固定ページはスコープ外)
entry/_draft/
以下に配置される_draft/
以下のエントリーファイル名を変更してDraftのままpushし直した場合_draft/
以下でファイル名を変更してpushすると、元ファイル名に戻る_draft/
の外に出してpushすると、新しいファイル名がCustomPathとして扱われ、ファイル位置は保持される2023/10/23/121212.md
)はその限りではない_draft/
以下に戻され、公開の場合、自動付与されたパスの位置に保存されることになる