diff --git a/components/helpers/read-yaml-file.js b/components/helpers/read-yaml-file.js index 02c6039cccc..8cfbe521746 100644 --- a/components/helpers/read-yaml-file.js +++ b/components/helpers/read-yaml-file.js @@ -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; diff --git a/config/casestudies/adeo.yml b/config/casestudies/adeo.yml index 2598c854a61..cd69dfece77 100644 --- a/config/casestudies/adeo.yml +++ b/config/casestudies/adeo.yml @@ -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 diff --git a/lib/staticHelpers.js b/lib/staticHelpers.js index 071b065805d..bc0fb991c6c 100644 --- a/lib/staticHelpers.js +++ b/lib/staticHelpers.js @@ -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 @@ -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, + } ]; } \ No newline at end of file diff --git a/pages/casestudies/[id].js b/pages/casestudies/[id].js index 096175ebc1e..e1374590bfe 100644 --- a/pages/casestudies/[id].js +++ b/pages/casestudies/[id].js @@ -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 = @@ -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: { @@ -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), }, }; } @@ -111,7 +111,7 @@ function Index({ asyncapiBindings, asyncapiTools, additionalResources, - examples, + fullExample, }) { const image = "/img/social/website-card.png"; const allComponents = getMDXComponents(); @@ -136,7 +136,7 @@ function Index({ asyncapiTools, additionalResources, casestudy, - examples, + fullExample, }); return (