Skip to content

Commit

Permalink
feat: removed news page
Browse files Browse the repository at this point in the history
  • Loading branch information
Guiso92 committed Mar 19, 2024
1 parent 9fa5e55 commit 49306af
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 15 deletions.
2 changes: 2 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const CATEGORIES_TO_HIDE: number[] = [
4409778008599, 4410571554839, 4410629239959,
];

export const MENU_CATEGORIES_TO_HIDE: number[] = [4410571554839, 4410629239959];

// A map from a locale code to Zendesk locale id used for dynamic content translations.
// https://developer.zendesk.com/api-reference/ticketing/account-configuration/locales/
// Keep in sync with locales configured in /next.config.js.
Expand Down
5 changes: 0 additions & 5 deletions lib/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ export function getMenuItems(
label: strings.services,
href: '/#service-map',
});
items.push({
key: 'news',
label: strings.news,
href: '/news',
});
if (includeAbout) {
items.push({
key: 'about',
Expand Down
15 changes: 13 additions & 2 deletions pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
CATEGORIES_TO_HIDE,
CATEGORY_ICON_NAMES,
GOOGLE_ANALYTICS_IDS,
MENU_CATEGORIES_TO_HIDE,
REVALIDATION_TIMEOUT_SECONDS,
SEARCH_BAR_INDEX,
SECTION_ICON_NAMES,
Expand Down Expand Up @@ -98,6 +99,7 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {
const strings: Custom404Strings = populateCustom404Strings(dynamicContent);

let categories: ZendeskCategory[] | CategoryWithSections[];
let menuCategories: ZendeskCategory[] | CategoryWithSections[];
if (USE_CAT_SEC_ART_CONTENT_STRUCTURE) {
categories = await getCategoriesWithSections(
currentLocale,
Expand All @@ -109,12 +111,21 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {
(s) => (s.icon = SECTION_ICON_NAMES[s.id] || 'help_outline')
);
});
menuCategories = await getCategoriesWithSections(
currentLocale,
getZendeskUrl(),
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);
} else {
categories = await getCategories(currentLocale, getZendeskUrl());
categories = categories.filter((c) => !CATEGORIES_TO_HIDE.includes(c.id));
categories.forEach(
(c) => (c.icon = CATEGORY_ICON_NAMES[c.id] || 'help_outline')
);
menuCategories = await getCategories(currentLocale, getZendeskUrl());
menuCategories = menuCategories.filter(
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);
}

const aboutUsArticle = await getArticle(
Expand All @@ -126,12 +137,12 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {
);
const menuOverlayItems = getMenuItems(
populateMenuOverlayStrings(dynamicContent),
categories,
menuCategories,
!!aboutUsArticle
);
const footerLinks = getFooterItems(
populateMenuOverlayStrings(dynamicContent),
categories
menuCategories
);
return {
props: {
Expand Down
16 changes: 14 additions & 2 deletions pages/articles/[article].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
CATEGORIES_TO_HIDE,
CATEGORY_ICON_NAMES,
GOOGLE_ANALYTICS_IDS,
MENU_CATEGORIES_TO_HIDE,
REVALIDATION_TIMEOUT_SECONDS,
SEARCH_BAR_INDEX,
SECTION_ICON_NAMES,
Expand Down Expand Up @@ -212,6 +213,7 @@ export const getStaticProps: GetStaticProps = async ({
);

let categories: ZendeskCategory[] | CategoryWithSections[];
let menuCategories: ZendeskCategory[] | CategoryWithSections[];
if (USE_CAT_SEC_ART_CONTENT_STRUCTURE) {
categories = await getCategoriesWithSections(
currentLocale,
Expand All @@ -223,13 +225,23 @@ export const getStaticProps: GetStaticProps = async ({
(s) => (s.icon = SECTION_ICON_NAMES[s.id] || 'help_outline')
);
});
menuCategories = await getCategoriesWithSections(
currentLocale,
getZendeskUrl(),
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);
} else {
categories = await getCategories(currentLocale, getZendeskUrl());
categories = categories.filter((c) => !CATEGORIES_TO_HIDE.includes(c.id));
categories.forEach(
(c) => (c.icon = CATEGORY_ICON_NAMES[c.id] || 'help_outline')
);
menuCategories = await getCategories(currentLocale, getZendeskUrl());
menuCategories = menuCategories.filter(
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);
}

const aboutUsArticle = await getArticle(
currentLocale,
ABOUT_US_ARTICLE_ID,
Expand All @@ -239,15 +251,15 @@ export const getStaticProps: GetStaticProps = async ({
);
const menuOverlayItems = getMenuItems(
populateMenuOverlayStrings(dynamicContent),
categories,
menuCategories,
!!aboutUsArticle
);

const strings = populateArticlePageStrings(dynamicContent);

const footerLinks = getFooterItems(
populateMenuOverlayStrings(dynamicContent),
categories
menuCategories
);

const article = await getArticle(
Expand Down
15 changes: 13 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
DIRECTUS_COUNTRY_ID,
DIRECTUS_INSTANCE,
GOOGLE_ANALYTICS_IDS,
MENU_CATEGORIES_TO_HIDE,
REVALIDATION_TIMEOUT_SECONDS,
SEARCH_BAR_INDEX,
SECTION_ICON_NAMES,
Expand Down Expand Up @@ -143,6 +144,7 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {
);

let categories: ZendeskCategory[] | CategoryWithSections[];
let menuCategories: ZendeskCategory[] | CategoryWithSections[];
if (USE_CAT_SEC_ART_CONTENT_STRUCTURE) {
categories = await getCategoriesWithSections(
currentLocale,
Expand All @@ -154,12 +156,21 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {
(s) => (s.icon = SECTION_ICON_NAMES[s.id] || 'help_outline')
);
});
menuCategories = await getCategoriesWithSections(
currentLocale,
getZendeskUrl(),
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);
} else {
categories = await getCategories(currentLocale, getZendeskUrl());
categories = categories.filter((c) => !CATEGORIES_TO_HIDE.includes(c.id));
categories.forEach(
(c) => (c.icon = CATEGORY_ICON_NAMES[c.id] || 'help_outline')
);
menuCategories = await getCategories(currentLocale, getZendeskUrl());
menuCategories = menuCategories.filter(
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);
}

const aboutUsArticle = await getArticle(
Expand All @@ -173,7 +184,7 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {

const menuOverlayItems = getMenuItems(
populateMenuOverlayStrings(dynamicContent),
categories,
menuCategories,
!!aboutUsArticle
);

Expand Down Expand Up @@ -287,7 +298,7 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {

const footerLinks = getFooterItems(
populateMenuOverlayStrings(dynamicContent),
categories
menuCategories
);

return {
Expand Down
15 changes: 13 additions & 2 deletions pages/search-results-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
CATEGORIES_TO_HIDE,
CATEGORY_ICON_NAMES,
GOOGLE_ANALYTICS_IDS,
MENU_CATEGORIES_TO_HIDE,
REVALIDATION_TIMEOUT_SECONDS,
SEARCH_BAR_INDEX,
SEARCH_RESULTS_PAGE_INDEX,
Expand Down Expand Up @@ -106,6 +107,7 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {
);

let categories: ZendeskCategory[] | CategoryWithSections[];
let menuCategories: ZendeskCategory[] | CategoryWithSections[];
if (USE_CAT_SEC_ART_CONTENT_STRUCTURE) {
categories = await getCategoriesWithSections(
currentLocale,
Expand All @@ -117,12 +119,21 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {
(s) => (s.icon = SECTION_ICON_NAMES[s.id] || 'help_outline')
);
});
menuCategories = await getCategoriesWithSections(
currentLocale,
getZendeskUrl(),
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);
} else {
categories = await getCategories(currentLocale, getZendeskUrl());
categories = categories.filter((c) => !CATEGORIES_TO_HIDE.includes(c.id));
categories.forEach(
(c) => (c.icon = CATEGORY_ICON_NAMES[c.id] || 'help_outline')
);
menuCategories = await getCategories(currentLocale, getZendeskUrl());
menuCategories = menuCategories.filter(
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);
}

const aboutUsArticle = await getArticle(
Expand All @@ -135,14 +146,14 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => {

const menuOverlayItems = getMenuItems(
populateMenuOverlayStrings(dynamicContent),
categories,
menuCategories,
!!aboutUsArticle
);

const strings = populateSearchResultsPageStrings(dynamicContent);
const footerLinks = getFooterItems(
populateMenuOverlayStrings(dynamicContent),
categories
menuCategories
);
return {
props: {
Expand Down
11 changes: 9 additions & 2 deletions pages/sections/[section].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
ABOUT_US_ARTICLE_ID,
CATEGORIES_TO_HIDE,
GOOGLE_ANALYTICS_IDS,
MENU_CATEGORIES_TO_HIDE,
REVALIDATION_TIMEOUT_SECONDS,
SEARCH_BAR_INDEX,
SECTION_ICON_NAMES,
Expand Down Expand Up @@ -228,6 +229,12 @@ export const getStaticProps: GetStaticProps = async ({ params, locale }) => {
);
});

const menuCategories = await getCategoriesWithSections(
currentLocale,
getZendeskUrl(),
(c) => !MENU_CATEGORIES_TO_HIDE.includes(c.id)
);

const sectionItems = categories
.flatMap((c) => c.sections)
.map((section) => {
Expand All @@ -249,13 +256,13 @@ export const getStaticProps: GetStaticProps = async ({ params, locale }) => {

const menuOverlayItems = getMenuItems(
populateMenuOverlayStrings(dynamicContent),
categories,
menuCategories,
!!aboutUsArticle
);

const footerLinks = getFooterItems(
populateMenuOverlayStrings(dynamicContent),
categories
menuCategories
);

return {
Expand Down

0 comments on commit 49306af

Please sign in to comment.