From 01df22c01d962629bacccf3f7200763b669cdafb Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:32:49 -0300 Subject: [PATCH 01/13] feat: return 404 if tutorial status is not published --- src/pages/docs/tutorial/[slug].tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/docs/tutorial/[slug].tsx b/src/pages/docs/tutorial/[slug].tsx index 9b52cfad..d930d8d5 100644 --- a/src/pages/docs/tutorial/[slug].tsx +++ b/src/pages/docs/tutorial/[slug].tsx @@ -385,6 +385,13 @@ export const getServerSideProps: GetServerSideProps = async ({ }, }) + // Check the frontmatter status + if (serialized.frontmatter?.status !== 'PUBLISHED') { + return { + notFound: true, + } + } + serialized = JSON.parse(JSON.stringify(serialized)) logger.info(`Processing ${slug}`) From c59ad83c4e89ea31b87b56c9d1944eee4d7c369c Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:32:59 -0300 Subject: [PATCH 02/13] feat: return 404 if track status is not published --- src/pages/docs/tracks/[slug].tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/docs/tracks/[slug].tsx b/src/pages/docs/tracks/[slug].tsx index df0cb392..c0a18978 100644 --- a/src/pages/docs/tracks/[slug].tsx +++ b/src/pages/docs/tracks/[slug].tsx @@ -294,6 +294,13 @@ export const getServerSideProps: GetServerSideProps = async ({ }, }) + // Check the frontmatter status + if (serialized.frontmatter?.status !== 'PUBLISHED') { + return { + notFound: true, + } + } + const sidebarfallback = await getNavigation() serialized = JSON.parse(JSON.stringify(serialized)) From ac157193761d9a2c293668a18f75fbf8d02593d8 Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:33:16 -0300 Subject: [PATCH 03/13] feat: return 404 if faq status is not published --- src/pages/faq/[slug].tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pages/faq/[slug].tsx b/src/pages/faq/[slug].tsx index ae467250..7568883c 100644 --- a/src/pages/faq/[slug].tsx +++ b/src/pages/faq/[slug].tsx @@ -184,6 +184,19 @@ export const getStaticProps: GetStaticProps = async ({ .then((res) => res.text()) .catch((err) => console.log(err))) || '' + // Serialize content and parse frontmatter + const serialized = await serialize(documentationContent, { + parseFrontmatter: true, + }) + + // Check if status is "PUBLISHED" + const isPublished = serialized?.frontmatter?.status === 'PUBLISHED' + if (!isPublished) { + return { + notFound: true, + } + } + const contributors = (await fetch( `https://github.com/vtexdocs/help-center-content/file-contributors/${branch}/${path}`, From 369338ffd00a7447939447e864a3213b861deb13 Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:33:27 -0300 Subject: [PATCH 04/13] feat: return 404 if troubleshooting status is not published --- src/pages/troubleshooting/[slug].tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pages/troubleshooting/[slug].tsx b/src/pages/troubleshooting/[slug].tsx index 3f5687c7..7a32ce1b 100644 --- a/src/pages/troubleshooting/[slug].tsx +++ b/src/pages/troubleshooting/[slug].tsx @@ -169,6 +169,19 @@ export const getStaticProps: GetStaticProps = async ({ .then((res) => res.text()) .catch((err) => console.log(err))) || '' + // Serialize content and parse frontmatter + const serialized = await serialize(documentationContent, { + parseFrontmatter: true, + }) + + // Check if status is "PUBLISHED" + const isPublished = serialized?.frontmatter?.status === 'PUBLISHED' + if (!isPublished) { + return { + notFound: true, + } + } + const contributors = (await fetch( `https://github.com/vtexdocs/help-center-content/file-contributors/${branch}/${path}`, From 64ad5fe71509deacc225539006ad7d4491537e25 Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:34:03 -0300 Subject: [PATCH 05/13] feat: return 404 if ki status is not published --- src/pages/known-issues/[slug].tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pages/known-issues/[slug].tsx b/src/pages/known-issues/[slug].tsx index a8417d49..77b0ce93 100644 --- a/src/pages/known-issues/[slug].tsx +++ b/src/pages/known-issues/[slug].tsx @@ -195,6 +195,19 @@ export const getStaticProps: GetStaticProps = async ({ .then((res) => res.text()) .catch((err) => console.log(err))) || '' + // Serialize content and parse frontmatter + const serialized = await serialize(documentationContent, { + parseFrontmatter: true, + }) + + // Check if status is "PUBLISHED" + const isPublished = serialized?.frontmatter?.status === 'PUBLISHED' + if (!isPublished) { + return { + notFound: true, + } + } + const contributors = (await fetch( `https://github.com/vtexdocs/help-center-content/file-contributors/${branch}/${path}`, From fa4ca8bebc26821c73db30e80914d528115ca798 Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:34:18 -0300 Subject: [PATCH 06/13] feat: return 404 if announcement status is not published --- src/pages/announcements/[slug].tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/pages/announcements/[slug].tsx b/src/pages/announcements/[slug].tsx index a996eef1..384ec71d 100644 --- a/src/pages/announcements/[slug].tsx +++ b/src/pages/announcements/[slug].tsx @@ -183,7 +183,7 @@ export const getStaticProps: GetStaticProps = async ({ const logger = getLogger('Announcements') - const path = docsPaths[slug].find((e) => e.locale === locale)?.path + const path = docsPaths[slug]?.find((e) => e.locale === locale)?.path if (!path) { return { @@ -198,6 +198,20 @@ export const getStaticProps: GetStaticProps = async ({ .then((res) => res.text()) .catch((err) => console.log(err))) || '' + // Serialize content and parse frontmatter + let serialized = await serialize(documentationContent, { + parseFrontmatter: true, + }) + + // Check if status is "PUBLISHED" + const isPublished = serialized?.frontmatter?.status === 'PUBLISHED' + if (!isPublished) { + return { + notFound: true, + } + } + + // Process the rest of the data const contributors = (await fetch( `https://github.com/vtexdocs/help-center-content/file-contributors/${branch}/${path}`, @@ -244,7 +258,7 @@ export const getStaticProps: GetStaticProps = async ({ try { const headingList: Item[] = [] - let serialized = await serialize(documentationContent, { + serialized = await serialize(documentationContent, { parseFrontmatter: true, mdxOptions: { remarkPlugins: [ @@ -292,6 +306,7 @@ export const getStaticProps: GetStaticProps = async ({ title: serialized.frontmatter?.title ?? seeAlsoUrl, createdAt: String(serialized.frontmatter?.createdAt) ?? '', updatedAt: String(serialized.frontmatter?.updatedAt) ?? '', + status: serialized.frontmatter?.status ?? '', }) } catch (error) {} } From 7d932cd4c8631fd5cda69d8102dcfc05de61f54f Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:34:37 -0300 Subject: [PATCH 07/13] feat: filter out announcements from list if not published --- src/pages/announcements/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/announcements/index.tsx b/src/pages/announcements/index.tsx index c90893ad..e2722ff7 100644 --- a/src/pages/announcements/index.tsx +++ b/src/pages/announcements/index.tsx @@ -43,9 +43,11 @@ const AnnouncementsPage: NextPage = ({ announcementsData, branch }) => { const [sortByValue, setSortByValue] = useState('newest') const filteredResult = useMemo(() => { - const data = announcementsData.filter((announcement) => - announcement.title?.toLowerCase().includes(searchTerm.toLowerCase()) - ) + const data = announcementsData + .filter((announcement) => announcement.status === 'PUBLISHED') + .filter((announcement) => + announcement.title?.toLowerCase().includes(searchTerm.toLowerCase()) + ) data.sort((a, b) => { const dateA = @@ -215,6 +217,7 @@ export const getStaticProps: GetStaticProps = async ({ url: `announcements/${data.slug}`, createdAt: String(frontmatter.createdAt), updatedAt: String(frontmatter.updatedAt), + status: frontmatter.status ?? null, }) } catch (error) { logger.error(`${error}`) From b0943e58d2c716fc01b2a0706a33a38bcfed7495 Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:34:45 -0300 Subject: [PATCH 08/13] feat: filter out kis from list if not published --- src/pages/known-issues/index.tsx | 35 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/pages/known-issues/index.tsx b/src/pages/known-issues/index.tsx index 20d814d0..14a054a3 100644 --- a/src/pages/known-issues/index.tsx +++ b/src/pages/known-issues/index.tsx @@ -48,25 +48,27 @@ const KnownIssuesPage: NextPage = ({ knownIssuesData, branch }) => { const itemsPerPage = 8 const [pageIndex, setPageIndex] = useState({ curr: 1, total: 1 }) const [filters, setFilters] = useState<{ - status: string[] + kiStatus: string[] modules: string[] - }>({ status: [], modules: [] }) + }>({ kiStatus: [], modules: [] }) const [search, setSearch] = useState('') const [sortByValue, setSortByValue] = useState('newest') const filteredResult = useMemo(() => { - const data = knownIssuesData.filter((knownIssue) => { - const hasFilter: boolean = - (filters.status.length === 0 || - filters.status.includes(knownIssue.status)) && - (filters.modules.length === 0 || - filters.modules.includes(knownIssue.module)) + const data = knownIssuesData + .filter((knownIssue) => knownIssue.status === 'PUBLISHED') + .filter((knownIssue) => { + const hasFilter: boolean = + (filters.kiStatus.length === 0 || + filters.kiStatus.includes(knownIssue.kiStatus)) && + (filters.modules.length === 0 || + filters.modules.includes(knownIssue.module)) - const hasSearch: boolean = knownIssue.title - .toLowerCase() - .includes(search.toLowerCase()) - return hasFilter && hasSearch - }) + const hasSearch: boolean = knownIssue.title + .toLowerCase() + .includes(search.toLowerCase()) + return hasFilter && hasSearch + }) data.sort((a, b) => { const dateA = @@ -128,10 +130,10 @@ const KnownIssuesPage: NextPage = ({ knownIssuesData, branch }) => { tagFilter={knownIssuesStatusFilter(intl)} checkBoxFilter={knownIssuesModulesFilters(intl)} selectedCheckboxes={filters.modules} - selectedTags={filters.status} + selectedTags={filters.kiStatus} onApply={(newFilters) => setFilters({ - status: newFilters.tag, + kiStatus: newFilters.tag, modules: newFilters.checklist, }) } @@ -242,9 +244,10 @@ export const getStaticProps: GetStaticProps = async ({ title: frontmatter.title, module: frontmatter.tag, slug: data.slug, - status: frontmatter.kiStatus as KnownIssueStatus, + kiStatus: frontmatter.kiStatus as KnownIssueStatus, createdAt: String(frontmatter.createdAt), updatedAt: String(frontmatter.updatedAt), + status: frontmatter.status, }) } catch (error) { logger.error(`${error}`) From ed3cd051f4862998fb960b240b4baf47a73afa48 Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:35:06 -0300 Subject: [PATCH 09/13] feat: filter out troubleshooting from list if not published --- src/pages/troubleshooting/index.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pages/troubleshooting/index.tsx b/src/pages/troubleshooting/index.tsx index c308fa57..9c680e4a 100644 --- a/src/pages/troubleshooting/index.tsx +++ b/src/pages/troubleshooting/index.tsx @@ -45,12 +45,14 @@ const TroubleshootingPage: NextPage = ({ const [sortByValue, setSortByValue] = useState('newest') const filteredResult = useMemo(() => { - const data = troubleshootingData.filter((troubleshoot) => { - return ( - filters.length === 0 || - troubleshoot.tags.some((tag) => filters.includes(tag)) - ) - }) + const data = troubleshootingData + .filter((troubleshoot) => troubleshoot.status === 'PUBLISHED') + .filter((troubleshoot) => { + return ( + filters.length === 0 || + troubleshoot.tags.some((tag) => filters.includes(tag)) + ) + }) data.sort((a, b) => { const dateA = @@ -207,6 +209,7 @@ export async function getStaticProps({ createdAt: String(frontmatter.createdAt), updatedAt: String(frontmatter.updatedAt), tags: String(frontmatter.tags ?? '').split(','), + status: frontmatter.status, }) } } catch (error) { From acf001b13c2df0381475efee72f88016f1a3b84f Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:35:14 -0300 Subject: [PATCH 10/13] feat: filter out faq from list if not published --- src/pages/faq/index.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/pages/faq/index.tsx b/src/pages/faq/index.tsx index 64ed8122..631ed6a7 100644 --- a/src/pages/faq/index.tsx +++ b/src/pages/faq/index.tsx @@ -49,15 +49,17 @@ const FaqPage: NextPage = ({ faqData, branch }) => { ) const filteredResult = useMemo(() => { - const data = faqData.filter((question) => { - const hasFilter: boolean = - filters.length === 0 || filters.includes(question.productTeam) - const hasSearch: boolean = question.title - .toLowerCase() - .includes(search.toLowerCase()) - - return hasFilter && hasSearch - }) + const data = faqData + .filter((question) => question.status === 'PUBLISHED') + .filter((question) => { + const hasFilter: boolean = + filters.length === 0 || filters.includes(question.productTeam) + const hasSearch: boolean = question.title + .toLowerCase() + .includes(search.toLowerCase()) + + return hasFilter && hasSearch + }) data.sort((a, b) => { const dateA = @@ -266,6 +268,7 @@ export const getStaticProps: GetStaticProps = async ({ createdAt: String(frontmatter.createdAt), updatedAt: String(frontmatter.updatedAt), productTeam: frontmatter.productTeam, + status: frontmatter.status, }) } catch (error) { logger.error(`${error}`) From bad3ba2b63c7a42aa29ccde3569688d17bc1d7dd Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:36:10 -0300 Subject: [PATCH 11/13] feat: add status to data elements --- src/utils/typings/types.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/typings/types.ts b/src/utils/typings/types.ts index 94939989..5a1d31b1 100644 --- a/src/utils/typings/types.ts +++ b/src/utils/typings/types.ts @@ -69,11 +69,12 @@ export type KnownIssueStatus = export type KnownIssueDataElement = { title: string id: string - status: KnownIssueStatus + kiStatus: KnownIssueStatus module: string slug: string createdAt: string updatedAt: string + status: 'PUBLISHED' | 'DRAFT' | 'ARCHIVED' | 'CHANGED' | string } export type AnnouncementDataElement = { @@ -81,6 +82,7 @@ export type AnnouncementDataElement = { url: string createdAt: string updatedAt: string + status: 'PUBLISHED' | 'DRAFT' | 'ARCHIVED' | 'CHANGED' | string } export type SortByType = 'newest' | 'recently_updated' @@ -91,6 +93,7 @@ export type FaqCardDataElement = { createdAt: string updatedAt: string productTeam: string + status: 'PUBLISHED' | 'DRAFT' | 'ARCHIVED' | 'CHANGED' | string } export type TroubleshootingDataElement = { @@ -99,4 +102,5 @@ export type TroubleshootingDataElement = { tags: string[] createdAt: string updatedAt: string + status: 'PUBLISHED' | 'DRAFT' | 'ARCHIVED' | 'CHANGED' | string } From 1ef0792e1af77a819f0bd8b911424a89f9de7399 Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:36:39 -0300 Subject: [PATCH 12/13] fix: ki cards status labels --- src/components/known-issue-card/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/known-issue-card/index.tsx b/src/components/known-issue-card/index.tsx index 2e2726f3..ef289507 100644 --- a/src/components/known-issue-card/index.tsx +++ b/src/components/known-issue-card/index.tsx @@ -11,7 +11,7 @@ const KnownIssueCard = ({ title, id, module, - status, + kiStatus, slug, createdAt, updatedAt, @@ -24,9 +24,9 @@ const KnownIssueCard = ({ - + {intl.formatMessage({ - id: `known_issues_filter_status.${status.toLowerCase()}`, + id: `known_issues_filter_status.${kiStatus.toLowerCase()}`, })} From 8e1f74c6d1a0c764e7e4939cdd5056ecb57df57e Mon Sep 17 00:00:00 2001 From: julia-rabello Date: Tue, 12 Nov 2024 15:46:59 -0300 Subject: [PATCH 13/13] fix: add status property to announcements in index.tsx --- src/pages/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index bc39433c..3fa9933f 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -127,6 +127,7 @@ export const getStaticProps: GetStaticProps = async ({ url: `announcements/${data.slug}`, createdAt: String(frontmatter.createdAt), updatedAt: String(frontmatter.updatedAt), + status: frontmatter.status, }) } } catch (error) {