{"ast":null,"code":"import fs from \"fs\";\nimport { join } from \"path\";\nvar POSTS_DIRECTORY = join(process.cwd(), \"sigma/examples\");\n\n/**\n * Returns a cleaned ExampleType object from a full path.\n */\nexport function getExample(path) {\n  var slug = (path.match(/([^\\/\\.]+)(\\.[^\\.\\/]+)?$/) || [])[1];\n  var rawFileContent = fs.readFileSync(path, \"utf8\");\n  return {\n    name: slug,\n    code: rawFileContent,\n    codePath: path,\n    htmlPath: path\n  };\n}\n/**\n * Returns the list of all posts.\n */\n\nexport function getExamples() {\n  return fs.readdirSync(POSTS_DIRECTORY, {\n    withFileTypes: true\n  }).filter(function (dirent) {\n    return dirent.isFile();\n  }).map(function (dirent) {\n    return getExample(join(POSTS_DIRECTORY, dirent.name));\n  });\n}\n/**\n * Returns for a example the params required to build its permalink.\n */\n\nexport function getExampleParams(example) {\n  return {\n    example: example.name\n  };\n}\n/**\n * Finds and returns the example for a given name.\n */\n\nexport function findExample(name) {\n  var examples = getExamples();\n  return examples.find(function (example) {\n    return example.name === name;\n  });\n}\n/**\n * Returns the URL of a given example.\n */\n\nexport function getExampleURL(example) {\n  return \"/examples/\".concat(example.name);\n}","map":null,"metadata":{},"sourceType":"module"}