Skip to content
Snippets Groups Projects
  1. Jan 04, 2023
    • Isabella Skořepová's avatar
      Rename all the markdown files · a8a1ae32
      Isabella Skořepová authored
      ```
      import fs from 'fs'
      import path from 'path'
      
      for (const file of traverse('content/articles')) {
        if (!file.endsWith('.md')) continue
      
        const dir = file.replace(/\.md$/, '')
        fs.mkdirSync(dir)
        fs.renameSync(file, path.join(dir, path.basename(file)))
      }
      
      function traverse(pathname) {
        const stat = fs.statSync(pathname)
        if (stat.isFile()) {
          return [pathname]
        } else if (stat.isDirectory()) {
          return fs
            .readdirSync(pathname)
            .map((v) => traverse(path.join(pathname, v)))
            .flat()
        }
        return []
      }
      ```
      a8a1ae32
  2. Aug 15, 2020
  3. Jan 22, 2020
  4. Nov 06, 2019
  5. Jun 13, 2019
  6. Jan 16, 2017
  7. Apr 04, 2016
  8. Apr 03, 2016
  9. Feb 21, 2016
  10. Dec 01, 2013
Loading