feat: add YAML download support for SDG analysis output#54
Open
adarsh-7-satyam wants to merge 1 commit into
Open
feat: add YAML download support for SDG analysis output#54adarsh-7-satyam wants to merge 1 commit into
adarsh-7-satyam wants to merge 1 commit into
Conversation
Signed-off-by: Adarsh Satyam <adarsh5.satyam@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #53
Problem
The tool currently only supports downloading the SDG analysis output as a JSON file. Looking at
frontend/components/results.tsx, the download section had a single button — "Yes, Download SDG Analysis File" — which only generatedunsdg.json. There was no YAML support anywhere in the frontend, no YAML library installed, and no open issue or PR addressing this gap.What I Changed
frontend/components/results.tsx1. Added a
convertToYaml()helper functionSince no YAML library existed in the project and adding one would introduce an unnecessary dependency, I wrote a lightweight recursive helper function that converts any JavaScript object into a properly formatted YAML string. It handles:
-list formatting:,#, or newlinesThis keeps the implementation dependency-free and consistent with the project's philosophy of avoiding unnecessary packages.
2. Added a
handleDownloadYaml()functionMirrors the existing
handleDownload()function exactly — same data structure, same confidence summary calculation — but converts the output usingconvertToYaml()instead ofJSON.stringify(), sets the MIME type totext/yaml, and downloads the file asunsdg.yaml.3. Updated the download buttons
What the YAML output looks like
Testing Done
convertToYamlfunction added correctly at line 126handleDownloadYamlfunction added correctly at line 157package.jsonNotes