@brillout/docpress 0.15.10-commit-ef0b9a0 → 0.15.10-commit-b6b1605
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/CodeSnippets.tsx +5 -1
- package/detypePlugin.ts +67 -23
- package/dist/+config.js +1 -1
- package/dist/NavItemComponent.js +46 -38
- package/dist/components/CodeBlockTransformer.js +3 -2
- package/dist/components/CodeSnippets.js +83 -21
- package/dist/components/Comment.js +2 -1
- package/dist/components/FileRemoved.js +6 -4
- package/dist/components/HorizontalLine.js +2 -1
- package/dist/components/ImportMeta.js +3 -2
- package/dist/components/Link.js +50 -34
- package/dist/components/Note.js +29 -17
- package/dist/components/P.js +12 -1
- package/dist/components/RepoLink.js +9 -7
- package/dist/determineNavItemsColumnLayout.js +62 -48
- package/dist/detypePlugin.js +143 -40
- package/dist/parseMarkdownMini.js +17 -5
- package/dist/parsePageSections.js +82 -41
- package/dist/renderer/usePageContext.js +7 -6
- package/dist/resolvePageContext.js +103 -91
- package/dist/utils/Emoji/Emoji.js +21 -13
- package/dist/utils/assert.js +16 -14
- package/dist/utils/cls.js +1 -1
- package/dist/utils/contentMap.d.ts +9 -0
- package/dist/utils/contentMap.js +22 -0
- package/dist/utils/determineSectionUrlHash.js +5 -5
- package/dist/utils/filter.js +2 -2
- package/dist/utils/getGlobalObject.js +3 -3
- package/dist/utils/useSelectedLanguage.js +12 -11
- package/dist/vite.config.js +7 -7
- package/package.json +2 -2
- package/tsconfig.json +0 -1
- package/utils/contentMap.ts +34 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
|
|
3
|
+
export type ContentMap = {
|
|
4
|
+
/**
|
|
5
|
+
* @returns key
|
|
6
|
+
*/
|
|
7
|
+
add(title: string, sourceLength: number, content: string): string
|
|
8
|
+
get(key: string): string | undefined
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const createContentMap = (): ContentMap => {
|
|
12
|
+
const map = new Map<string, string>()
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
add(title, length, content) {
|
|
16
|
+
const key = generateKey(`${title}_${length}`)
|
|
17
|
+
if (!map.has(key)) {
|
|
18
|
+
map.set(key, content)
|
|
19
|
+
}
|
|
20
|
+
return key
|
|
21
|
+
},
|
|
22
|
+
get(key) {
|
|
23
|
+
const val = map.get(key)
|
|
24
|
+
return val
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const generateKey = (value: string) => {
|
|
30
|
+
const hash = createHash('md5').update(value).digest('hex')
|
|
31
|
+
return `#_#_${hash}_#_#`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const contentMapKeyRE = /#_#_[0-9a-fA-F]{32}_#_#/g
|