Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeTable Component #3309

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alex-fusionauth
Copy link
Contributor

No description provided.

@synedra
Copy link
Contributor

synedra commented Sep 26, 2024

This is a new component so we're asking a couple of developer folks to take a look.

@lyleschemmerling
Copy link
Contributor

If I add a markdown table at the bottom the results look the same to me. What does this buy us that we don't get from mdx?

import CodeTable from 'src/components/CodeTable.astro';
import * as md from 'src/components/dev-tools/alextesting_markdown.md'; // This could come from remote source
import AlexStuff from 'src/components/dev-tools/alextesting_markdown.md';


{/* With headings */}
<CodeTable 
    headings={[['file', 'code']]} 
    rows={[
    ['vite.config.ts', md.compiledContent()], 
    ['vite.config2.ts', md.compiledContent()]]
    } 
/>

{/* Without headings */}

<CodeTable 
    rows={[
    ['vite.config.ts', md.compiledContent()], 
    ['vite.config2.ts', md.compiledContent()]]
    } 
/>

| file            | code         |
|-----------------|--------------|
| vite.config.js  | <AlexStuff/> |
| vite.config2.js | <AlexStuff/> |

@synedra
Copy link
Contributor

synedra commented Sep 26, 2024 via email

@lyleschemmerling
Copy link
Contributor

lyleschemmerling commented Sep 26, 2024

While I am not sure that this component would solve the problem of needing to use fragment files I personally think that putting those code blocks in their own files feels cleaner to me.

However if you wanted to inline the code snippets anyway you could do something like this:

---
title: Code Table
description: Code Table Example.
author: Alex Patterson
---
import Code from 'astro/components/Code.astro';

export const code = `
export default defineConfig({
  plugins: [reactRefresh()],
  server: {
    fs: {
      strict: true,
    },
  },
  optimizeDeps: {
    include: ['@apollo/client', 'graphql'],
  },
});
`;

| file            | code                                   |
|-----------------|----------------------------------------|
| vite.config.js  | <Code lang='javascript' code={code} /> |
| vite.config2.js | <AlexStuff/>                           |

@synedra
Copy link
Contributor

synedra commented Sep 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants