Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

octicon-tag.js 846 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  1. #!/usr/bin/env node
  2. const path = require('path')
  3. const walk = require('walk-sync')
  4. const replace = require('replace')
  5. const FINDER = /{{\s?octicon-([a-z-]+)(\s[\w\s\d-]+)?\s?}}/g
  6. async function rewriteFiles (dir) {
  7. const files = walk(dir, { includeBasePath: true })
  8. replace({
  9. regex: FINDER,
  10. replacement: (match, p1, p2) => {
  11. if (p2) {
  12. return `{% octicon "${p1}" aria-label="${p2.trim()}" %}`
  13. } else {
  14. return `{% octicon "${p1}" %}`
  15. }
  16. },
  17. paths: files,
  18. recursive: true
  19. })
  20. }
  21. async function main () {
  22. const dirs = [
  23. path.join(__dirname, '../../content'),
  24. path.join(__dirname, '../../data'),
  25. path.join(__dirname, '../../translations')
  26. ]
  27. for (const dir of dirs) {
  28. await rewriteFiles(dir)
  29. }
  30. }
  31. main()
  32. .catch(console.error)
  33. .finally(() => console.log('Done!'))
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...