Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Commit

Permalink
feat: support yaml config format, fix #69
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee committed May 19, 2024
1 parent 5927d76 commit 692d5ff
Show file tree
Hide file tree
Showing 3 changed files with 2,271 additions and 1,797 deletions.
7 changes: 6 additions & 1 deletion components/EnvVariableConfig/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { useState } from 'react';
import copy from 'copy-to-clipboard';

export function EnvVariableConfig({ variableNames }) {
export function EnvVariableConfig({ variableNames, format }: { variableNames: { key: string; name: string }[]; format?: "yaml" | "env" }) {
const [values, setValues] = useState(Array(variableNames.length).fill(''));

const handleCopy = () => {
if (format === 'yaml') {
const yamlContent = variableNames.map((name, index) => `- ${name.key}: ${values[index]}`).join('\n');
copy(yamlContent);
return;
}
const envContent = variableNames.map((name, index) => `${name.key}=${values[index]}`).join('\n');
copy(envContent);
};
Expand Down
1 change: 1 addition & 0 deletions pages/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ wget https://fastly.jsdelivr.net/gh/mx-space/core@master/docker-compose.yml
import { EnvVariableConfig } from '@components/EnvVariableConfig'

<EnvVariableConfig
format="yaml"
variableNames={[
{
key: 'JWT_SECRET',
Expand Down
Loading

0 comments on commit 692d5ff

Please sign in to comment.