@wdprlib/parser 4.0.0 → 4.2.0

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.
Files changed (26) hide show
  1. package/README.md +9 -1
  2. package/dist/index.cjs +345 -64
  3. package/dist/index.d.cts +121 -2
  4. package/dist/index.d.ts +121 -2
  5. package/dist/index.js +317 -36
  6. package/package.json +2 -2
  7. package/src/index.ts +9 -0
  8. package/src/parser/rules/block/module/index.ts +10 -0
  9. package/src/parser/rules/block/module/listpages/extract.ts +9 -0
  10. package/src/parser/rules/block/module/listpages/extraction/tagcloud.ts +25 -0
  11. package/src/parser/rules/block/module/listpages/types/data-requirements.ts +2 -0
  12. package/src/parser/rules/block/module/listpages/url-resolution/fields.ts +4 -4
  13. package/src/parser/rules/block/module/listpages/url-resolution/params.ts +12 -1
  14. package/src/parser/rules/block/module/listpages/url-resolution/resolve.ts +10 -1
  15. package/src/parser/rules/block/module/listpages/url-resolution/value.ts +13 -4
  16. package/src/parser/rules/block/module/mapping.ts +2 -0
  17. package/src/parser/rules/block/module/resolution/contexts.ts +29 -1
  18. package/src/parser/rules/block/module/resolution/data-maps.ts +17 -0
  19. package/src/parser/rules/block/module/resolution/dynamic-modules.ts +29 -2
  20. package/src/parser/rules/block/module/resolution/walk-resolve.ts +28 -4
  21. package/src/parser/rules/block/module/resolve.ts +11 -1
  22. package/src/parser/rules/block/module/tagcloud/index.ts +15 -0
  23. package/src/parser/rules/block/module/tagcloud/parser.ts +127 -0
  24. package/src/parser/rules/block/module/tagcloud/resolve.ts +173 -0
  25. package/src/parser/rules/block/module/tagcloud/types.ts +85 -0
  26. package/src/parser/rules/block/module/types-common.ts +15 -0
package/README.md CHANGED
@@ -37,6 +37,14 @@ const resolved = await resolveModules(ast, {
37
37
  // Fetch pages matching query from your database
38
38
  return { pages: [...], totalCount: 100, site: { name: 'mysite' } }
39
39
  },
40
+ fetchTagCloud: async ({ category, limit }) => {
41
+ // Fetch up to `limit` tags (weight = page count) for `[[module TagCloud]]`,
42
+ // ordered by weight descending. `category` is the raw, untrusted attribute
43
+ // value — look it up with a parameterized query and return the normalized name
44
+ const found = category ? await findCategory(category) : null // your lookup
45
+ if (category && !found) return { status: 'category-not-found', category }
46
+ return { status: 'ok', tags: [{ tag: 'scp', weight: 42 }], category: found?.unixName ?? null }
47
+ },
40
48
  getPageTags: () => ['tag1', 'tag2'],
41
49
  }, {
42
50
  parse,
@@ -49,7 +57,7 @@ const resolved = await resolveModules(ast, {
49
57
 
50
58
  - Wikidot markup parsing (bold, italic, links, images, tables, etc.)
51
59
  - Include resolution (`[[include page]]`)
52
- - Module support (ListPages, ListUsers, IfTags, etc.)
60
+ - Module support (ListPages, ListUsers, TagCloud, IfTags, etc.)
53
61
  - Data extraction for server-side rendering
54
62
 
55
63
  ## Related Packages