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

replace hashids (bashids) with sqids #20

Closed
Pinjasaur opened this issue Jul 24, 2024 · 3 comments · Fixed by #23
Closed

replace hashids (bashids) with sqids #20

Pinjasaur opened this issue Jul 24, 2024 · 3 comments · Fixed by #23

Comments

@Pinjasaur
Copy link
Owner

https://sqids.org/bash

this'll be a breaking change because the IDs (used in the RSS feed) will change, but it'll also simply it all slightly by removing the SALT envar

@mfossen
Copy link
Contributor

mfossen commented Jul 24, 2024

Will this cause any issues (dupes etc.) to be sent via RSS after the change?

@Pinjasaur
Copy link
Owner Author

Pinjasaur commented Jul 24, 2024

yeah, it will cause dupes. I ended up ripping the bandaid off and doing this on my own a blog a couple years back: https://paul.af/breaking-rss-feed-changes

it's used like this right now: https://github.com/Pinjasaur/bic-example/blob/e4ef0ef54f175c4abc05e74f81e93277f49dc148/__feed.rss#L4-L5

here's the spec for guid: https://www.rssboard.org/rss-draft-1#element-channel-item-guid

here's the current implementation of mk_id as part of bic's internals:

bic/bic

Lines 106 to 114 in 5ebb854

mk_id() {
local id="${1%-"${2}"}"
if ! echo "${id:-}" | grep -Eq '^[[:digit:]]+$'; then
fatal "Number prefix is required: ${1}"
fi
local hashid
hashid="$("${__dir}"/lib/bashids -e -s "${SALT:-bic}" -l 28 "${id}")"
echo "${__base}_${hashid}"
}

it's imperfect, but I was intentional about doing it this way to still allow for changing the filename e.g. 000-foo.md -> 000-bar.md will go from /foo to /bar but will retain the same underlying id which will prevent dupes

I don't have a better idea on handling it offhand. thoughts @mfossen?

@Pinjasaur
Copy link
Owner Author

technically, could go with the bare number prefix e.g. 000 from 000-foo.md but wanted to make it more ID-like by using a library like hashids/sqids. there definitely won't be a 100% perfect solution, but I do like this overall: I've been bitten by renaming the files of already-published entries which unfortunately changed the underlying GUID for the RSS feed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants