feat(web): add yamlExport function
This commit is contained in:
13
web/src/utils/yamlExport.ts
Normal file
13
web/src/utils/yamlExport.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import yaml from 'js-yaml';
|
||||
|
||||
|
||||
export const exportToYaml = (data: unknown, filename: string = 'export.yaml') => {
|
||||
const yamlStr = yaml.dump(data);
|
||||
const blob = new Blob([yamlStr], { type: 'text/yaml' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
Reference in New Issue
Block a user