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. Nov 06, 2019
  4. Jun 13, 2019
  5. Oct 26, 2017
  6. Jan 21, 2017
  7. Jan 16, 2017
  8. Dec 29, 2016
  9. Feb 20, 2016
  10. Mar 11, 2014
Loading