Allow for customizing the size of generated comment IDs #9
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.
This addresses eduardoboucas#401 - "Allow for customizing the size of generated comment IDs"
Two new config options have been added to the JSON-based config:
Currently, Staticman creates all comment IDs as UUIDs. While using UUIDs is a fool-proof solution that basically guarantees the uniqueness of IDs, it can be overkill. Consider a small blog that receives, at most, one comment each day/week/month/etc. For many/most users, the nature of the IDs that Staticman generates will not matter. However, the Staticman configuration allows for the generated ID to be exposed, when desired. For example, it can be incorporated into the filenames generated by Staticman.
For usage scenarios such as these, it is desirable to be able to configure Staticman to generate shorter/simpler comment IDs. Nano ID has been added to achieve this.
For example, if
commentIdGenerator
is set tonanoid-lowercase
andcommentIdLength
is set to8
, IDs akin to the following will be generated:ry6-bt9d
According the the Nano ID Collision Calculator, for a blog receiving one comment submission every hour, "~34 years [would be] needed, in order to have a 1% probability of at least one collision".