Generate MDX content with either provided or generated frontmatter.
(notebook_path, processed_content, frontmatter=None)
| 116 | |
| 117 | |
| 118 | def generate_mdx_content(notebook_path, processed_content, frontmatter=None): |
| 119 | """Generate MDX content with either provided or generated frontmatter.""" |
| 120 | if not frontmatter: |
| 121 | # Generate new frontmatter |
| 122 | folder_name = Path(notebook_path).parent.name |
| 123 | |
| 124 | # Check for title override, otherwise use default title case conversion |
| 125 | if folder_name in TITLE_OVERRIDES: |
| 126 | base_title = TITLE_OVERRIDES[folder_name] |
| 127 | else: |
| 128 | base_title = folder_name.replace("_", " ").title() |
| 129 | |
| 130 | title = f"{base_title}" |
| 131 | |
| 132 | # Extract description from first heading or use default |
| 133 | description = f"{title} example using AgentOps" |
| 134 | for line in processed_content.split("\n"): |
| 135 | if line.startswith("# ") and len(line) > 2: |
| 136 | description = line[2:].strip() |
| 137 | break |
| 138 | |
| 139 | frontmatter = f"title: '{title}'\ndescription: '{description}'" |
| 140 | |
| 141 | return f"""--- |
| 142 | {frontmatter} |
| 143 | --- |
| 144 | {{/* SOURCE_FILE: {notebook_path} */}} |
| 145 | |
| 146 | _View Notebook on <a href={{'https://github.com/AgentOps-AI/agentops/blob/main/{notebook_path}'}} target={{'_blank'}}>Github</a>_ |
| 147 | |
| 148 | {processed_content} |
| 149 | |
| 150 | {SCRIPT_TAGS}""" |
| 151 | |
| 152 | |
| 153 | def main(): |
no outgoing calls
no test coverage detected
searching dependent graphs…