From ba0967e85942de690a1b8ef2304b3e52a8f9cbac Mon Sep 17 00:00:00 2001 From: dmick92 Date: Thu, 18 Jan 2024 10:07:32 -0500 Subject: [PATCH] Updated folder/files names to match convention --- components/docList/index.tsx | 75 +++++++++++++++++++ .../{zoho-icons => zohoIcons}/index.jsx | 2 +- .../zohoIcons.module.css} | 2 +- .../{product-icons.svg => productIcons.svg} | 0 ...m-salesiq.md => lookupToCrmFromSalesiq.md} | 0 .../{NextJS-Setup.mdx => nextJsSetup.mdx} | 0 .../{generate-UUID.md => generateUuid.md} | 0 pages/Deluge/_meta.json | 9 ++- .../filterListOfObjects.md} | 0 ...stom-field.md => searchWithCustomField.md} | 0 ...on-Template.md => contributionTemplate.md} | 0 ...-Cheatsheet.mdx => markdownCheatsheet.mdx} | 0 .../Sites/{custom-fonts.md => customFonts.md} | 0 ...aph-expansion.md => paragraphExpansion.md} | 0 pages/_meta.json | 18 ++--- pages/index.mdx | 2 +- 16 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 components/docList/index.tsx rename components/{zoho-icons => zohoIcons}/index.jsx (98%) rename components/{zoho-icons/zoho-icons.module.css => zohoIcons/zohoIcons.module.css} (68%) rename images/{product-icons.svg => productIcons.svg} (100%) rename pages/CRM/{lookup-to-crm-from-salesiq.md => lookupToCrmFromSalesiq.md} (100%) rename pages/Catalyst/{NextJS-Setup.mdx => nextJsSetup.mdx} (100%) rename pages/Deluge/Strings/{generate-UUID.md => generateUuid.md} (100%) rename pages/Deluge/{Lists/filter-list-of-objects.md => lists/filterListOfObjects.md} (100%) rename pages/Desk/{search-with-custom-field.md => searchWithCustomField.md} (100%) rename pages/Resources/{Contribution-Template.md => contributionTemplate.md} (100%) rename pages/Resources/{Markdown-Cheatsheet.mdx => markdownCheatsheet.mdx} (100%) rename pages/Sites/{custom-fonts.md => customFonts.md} (100%) rename pages/Sites/{paragraph-expansion.md => paragraphExpansion.md} (100%) diff --git a/components/docList/index.tsx b/components/docList/index.tsx new file mode 100644 index 0000000..e2533e7 --- /dev/null +++ b/components/docList/index.tsx @@ -0,0 +1,75 @@ +import { Cards, Card } from "nextra/components"; +import { useEffect, useState } from "react"; + +export const RawDocuments = async (folder) => { + return await fetch(`https://api.github.com/repos/nickmackenzie/dont-get-zohod/contents/pages/${folder}`) + .then(response => response.json()) + .catch(error => { + console.error('Error fetching file list:', error); + }); +} + +export const DocumentCards = (props) => { + const [documents, setDocuments] = useState([]) + + useEffect(() => { + const func = async () => { + const docList = [] + const documents = await RawDocuments(props.folder) + for (const document of documents.filter(doc => doc.name.includes(".md"))) { + const metadata = await FetchContent(document.git_url); + docList.push({ ...document, ...metadata }) + } + setDocuments(docList); + } + func() + }, []) + + const cards = documents?.sort((a, b) => { + let ta = a.title.toLowerCase(), tb = b.title.toLowerCase(); + //if {ta} is first else if {tb} is fist else 0 + return ta < tb ? -1 : ta > tb ? 1 : 0 + }).map((doc, index) => ( + + )) + + return ( + + {cards} + + ) +} + +const FetchContent = async (url) => { + return await fetch(url) + .then(response => response.json()) + .then(data => extractMetadataFromMarkdown(Buffer.from(data.content, 'base64').toString())) + .catch(error => { + console.error('Error fetching file list:', error); + }); +} + +const extractMetadataFromMarkdown = (markdown) => { + const charactersBetweenGroupedHyphens = /^---([\s\S]*?)---/; + const metadataMatched = markdown.match(charactersBetweenGroupedHyphens); + const metadata = metadataMatched[1]; + + if (!metadata) { + return {}; + } + + const metadataLines = metadata.split("\n"); + const metadataObject = metadataLines.reduce((accumulator, line) => { + const [key, ...value] = line.split(":").map((part) => part.trim()); + + if (key) + accumulator[key] = value[1] ? value.join(":") : value.join(""); + return accumulator; + }, {}); + + return metadataObject; +}; \ No newline at end of file diff --git a/components/zoho-icons/index.jsx b/components/zohoIcons/index.jsx similarity index 98% rename from components/zoho-icons/index.jsx rename to components/zohoIcons/index.jsx index 60b6d5f..a7c43fe 100644 --- a/components/zoho-icons/index.jsx +++ b/components/zohoIcons/index.jsx @@ -1,4 +1,4 @@ -import styles from "./zoho-icons.module.css"; +import styles from "./zohoIcons.module.css"; const IconBase = (props) => { return ; diff --git a/components/zoho-icons/zoho-icons.module.css b/components/zohoIcons/zohoIcons.module.css similarity index 68% rename from components/zoho-icons/zoho-icons.module.css rename to components/zohoIcons/zohoIcons.module.css index a19f1e9..5312669 100644 --- a/components/zoho-icons/zoho-icons.module.css +++ b/components/zohoIcons/zohoIcons.module.css @@ -1,5 +1,5 @@ .zicon{ - background: url(../../images/product-icons.svg) no-repeat; + background: url(../../images/productIcons.svg) no-repeat; background-size: 800px auto; width: 40px; height: 40px; diff --git a/images/product-icons.svg b/images/productIcons.svg similarity index 100% rename from images/product-icons.svg rename to images/productIcons.svg diff --git a/pages/CRM/lookup-to-crm-from-salesiq.md b/pages/CRM/lookupToCrmFromSalesiq.md similarity index 100% rename from pages/CRM/lookup-to-crm-from-salesiq.md rename to pages/CRM/lookupToCrmFromSalesiq.md diff --git a/pages/Catalyst/NextJS-Setup.mdx b/pages/Catalyst/nextJsSetup.mdx similarity index 100% rename from pages/Catalyst/NextJS-Setup.mdx rename to pages/Catalyst/nextJsSetup.mdx diff --git a/pages/Deluge/Strings/generate-UUID.md b/pages/Deluge/Strings/generateUuid.md similarity index 100% rename from pages/Deluge/Strings/generate-UUID.md rename to pages/Deluge/Strings/generateUuid.md diff --git a/pages/Deluge/_meta.json b/pages/Deluge/_meta.json index 059d160..e28065b 100644 --- a/pages/Deluge/_meta.json +++ b/pages/Deluge/_meta.json @@ -1,3 +1,6 @@ -{ - "TimeDates":"Time & Dates" -} \ No newline at end of file +{ + "buttons": "Buttons", + "lists": "Lists", + "strings": "Strings", + "timeDates": "Time & Dates" +} diff --git a/pages/Deluge/Lists/filter-list-of-objects.md b/pages/Deluge/lists/filterListOfObjects.md similarity index 100% rename from pages/Deluge/Lists/filter-list-of-objects.md rename to pages/Deluge/lists/filterListOfObjects.md diff --git a/pages/Desk/search-with-custom-field.md b/pages/Desk/searchWithCustomField.md similarity index 100% rename from pages/Desk/search-with-custom-field.md rename to pages/Desk/searchWithCustomField.md diff --git a/pages/Resources/Contribution-Template.md b/pages/Resources/contributionTemplate.md similarity index 100% rename from pages/Resources/Contribution-Template.md rename to pages/Resources/contributionTemplate.md diff --git a/pages/Resources/Markdown-Cheatsheet.mdx b/pages/Resources/markdownCheatsheet.mdx similarity index 100% rename from pages/Resources/Markdown-Cheatsheet.mdx rename to pages/Resources/markdownCheatsheet.mdx diff --git a/pages/Sites/custom-fonts.md b/pages/Sites/customFonts.md similarity index 100% rename from pages/Sites/custom-fonts.md rename to pages/Sites/customFonts.md diff --git a/pages/Sites/paragraph-expansion.md b/pages/Sites/paragraphExpansion.md similarity index 100% rename from pages/Sites/paragraph-expansion.md rename to pages/Sites/paragraphExpansion.md diff --git a/pages/_meta.json b/pages/_meta.json index 9161dde..2e23e41 100644 --- a/pages/_meta.json +++ b/pages/_meta.json @@ -2,23 +2,23 @@ "index": { "title": "Introduction" }, - "Contributing": "Contributing", + "contributing": "Contributing", "---": { "type": "separator" }, - "Deluge": "Deluge", + "deluge": "Deluge", "-- Apps": { "type": "separator", "title": "Apps" }, - "Catalyst": "Catalyst", - "Commerce": "Commerce", - "Creator": "Creator", - "CRM": "CRM", - "Desk": "Desk", - "Sites": "Sites", + "catalyst": "Catalyst", + "commerce": "Commerce", + "creator": "Creator", + "crm": "CRM", + "desk": "Desk", + "sites": "Sites", "-- Resources": { "type": "separator" }, - "Resources": "Resources" + "resources": "Resources" } diff --git a/pages/index.mdx b/pages/index.mdx index 3eb3529..84b7ebc 100644 --- a/pages/index.mdx +++ b/pages/index.mdx @@ -7,7 +7,7 @@ import { DeskIcon, DelugeIcon, SitesIcon, -} from "../components/zoho-icons"; +} from "../components/zohoIcons"; # Don't Get Zohod 🚫