Skip to content

Commit

Permalink
fix: remove redundancy and improve consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
akkshitgupta committed Mar 24, 2024
1 parent b88bc73 commit 4da9adc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion components/helpers/read-yaml-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs/promises';

export const readYamlFile = async (fileName) => {
try {
const data = await fs.readFile(fileName, 'utf-8');
const data = await fs.readFile(`./public/${fileName}`, 'utf-8');
const yamlString = `\`\`\`yaml\n${data}\`\`\``;

return yamlString;
Expand Down
1 change: 0 additions & 1 deletion config/casestudies/adeo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,3 @@ asyncapi:
* [AsyncAPI JavaScript Parser](https://github.com/asyncapi/parser-js) with [Avro Schema Parser](https://github.com/asyncapi/avro-schema-parser).
fullExample: resources/casestudies/adeo/asyncapi.yaml
additionalResources: Watch [this video presentation about AsyncAPI case study](https://www.youtube.com/watch?v=WwhRbvrf6Rs) from Ludovic Dussart, Ineat & Antoine Delequeuche, Adeo.
examples: ./public/resources/casestudies/adeo/asyncapi.yaml
10 changes: 5 additions & 5 deletions lib/staticHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function getEvents(events, size) {
}

export const generateCaseStudyContent = (data) => {
const { challenges, solution, usecase, architecture, testing, codegen, schemaStorage, registry, versioning, validation, asyncapiStorage, asyncapiEditing, asyncapiExtensions, asyncapiDocumentation, asyncapiBindings, asyncapiTools, additionalResources, casestudy, examples } = data;
const { challenges, solution, usecase, architecture, testing, codegen, schemaStorage, registry, versioning, validation, asyncapiStorage, asyncapiEditing, asyncapiExtensions, asyncapiDocumentation, asyncapiBindings, asyncapiTools, additionalResources, casestudy, fullExample } = data;
const languages= casestudy.technical.languages
const frameworks=casestudy.technical.frameworks
const protocols=casestudy.technical.protocols
Expand Down Expand Up @@ -197,13 +197,13 @@ export const generateCaseStudyContent = (data) => {
title: "Additional Resources",
content: additionalResources,
},
{
title: "Production-use AsyncAPI document",
content: examples,
}
],
},
],
},
{
title: "Production-use AsyncAPI document",
content: fullExample,
}
];
}
10 changes: 5 additions & 5 deletions pages/casestudies/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { serialize } from "next-mdx-remote/serialize";
import GenericLayout from "../../components/layout/GenericLayout";
import CaseTOC from "../../components/CaseTOC";
import { generateCaseStudyContent } from "../../lib/staticHelpers";
import { readYamlFile } from '../../components/helpers/read-yaml-file.js'
import { readYamlFile } from '../../components/helpers/read-yaml-file.js';

const renderContent = (content, allComponents, level) => {
const typeStyle =
Expand Down Expand Up @@ -55,7 +55,7 @@ const renderContent = (content, allComponents, level) => {

export async function getStaticProps({ params }) {
const data = CaseStudiesList.filter((p) => p.id === params.id);
const asyncapiDoc = await readYamlFile(data[0].examples);
const asyncapiDoc = await readYamlFile(data[0].asyncapi.fullExample);

return {
props: {
Expand All @@ -77,7 +77,7 @@ export async function getStaticProps({ params }) {
asyncapiBindings: await serialize(data[0].asyncapi.bindings),
asyncapiTools: await serialize(data[0].asyncapi.tools),
additionalResources: await serialize(data[0].additionalResources),
examples: await serialize(asyncapiDoc),
fullExample: await serialize(asyncapiDoc),
},
};
}
Expand Down Expand Up @@ -111,7 +111,7 @@ function Index({
asyncapiBindings,
asyncapiTools,
additionalResources,
examples,
fullExample,
}) {
const image = "/img/social/website-card.png";
const allComponents = getMDXComponents();
Expand All @@ -136,7 +136,7 @@ function Index({
asyncapiTools,
additionalResources,
casestudy,
examples,
fullExample,
});

return (
Expand Down

0 comments on commit 4da9adc

Please sign in to comment.