MCPcopy
hub / github.com/npmx-dev/npmx.dev / generateBlogTID

Function generateBlogTID

shared/utils/atproto.ts:17–27  ·  view source on GitHub ↗
(dateString: string, slug: string)

Source from the content-addressed store, hash-verified

15
16// Parse date from frontmatter, add slug-path entropy for same-date collision resolution
17export const generateBlogTID = (dateString: string, slug: string): string => {
18 let timestamp = Date.parse(dateString)
19
20 if (timestamp % ONE_DAY_MILLISECONDS === 0) {
21 const offset = simpleHash(slug) % 1000000
22 timestamp += offset
23 }
24
25 // Clock id(3) needs to be the same everytime to get the same TID from a timestamp
26 return TID.create(timestamp * MS_TO_MICROSECONDS, TID_CLOCK_ID)
27}
28
29// Using our release date as the tid for the publication
30export const npmxPublicationRkey = () =>

Callers 1

syncFileFunction · 0.90

Calls 1

simpleHashFunction · 0.70

Tested by

no test coverage detected