{"ast":null,"code":"import fs from \"fs\";\nimport { join } from \"path\";\nimport hljs from \"highlight.js\";\nimport examples from \"../../examples/.examples.json\";\nconst POSTS_DIRECTORY = join(process.cwd(), \"../examples\");\n/**\n * Returns a cleaned ExampleType object from a full path.\n */\n\nexport function getExample(path) {\n  const slug = (path.match(/([^\\/\\.]+)(\\.[^\\.\\/]+)?$/) || [])[1];\n  const rawFileContent = fs.readFileSync(path, \"utf8\");\n  return {\n    name: slug,\n    codeRaw: rawFileContent,\n    codeHTML: hljs.highlightAuto(rawFileContent).value,\n    codePath: path,\n    htmlPath: path,\n    iframePath: `/demos/${slug}.html`\n  };\n}\n/**\n * Returns the list of all posts.\n */\n\nexport function getExamples() {\n  return Object.values(examples).map(example => getExample(join(POSTS_DIRECTORY, example.id + \".ts\")));\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  const examples = getExamples();\n  return examples.find(example => example.name === name);\n}","map":null,"metadata":{},"sourceType":"module"}