Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions app/[locale]/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,26 @@ import {
setRequestLocale,
} from "next-intl/server"

import type { SlugPageParams } from "@/lib/types"
import type { GHIssue, SlugPageParams } from "@/lib/types"

import I18nProvider from "@/components/I18nProvider"
import mdComponents from "@/components/MdComponents"

import { dataLoader } from "@/lib/utils/data/dataLoader"
import { dateToString } from "@/lib/utils/date"
import { getLayoutFromSlug } from "@/lib/utils/layout"
import { checkPathValidity, getPostSlugs } from "@/lib/utils/md"
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"

import { getGFIs } from "@/data-layer"

import { LOCALES_CODES } from "@/lib/constants"

import SlugJsonLD from "./page-jsonld"

import { componentsMapping, layoutMapping } from "@/layouts"
import { fetchGFIs } from "@/lib/api/fetchGFIs"
import { getPageData } from "@/lib/md/data"
import { getMdMetadata } from "@/lib/md/metadata"

const loadData = dataLoader([["gfissues", fetchGFIs]])

export default async function Page({ params }: { params: SlugPageParams }) {
const { locale, slug: slugArray } = params

Expand All @@ -40,7 +38,12 @@ export default async function Page({ params }: { params: SlugPageParams }) {
// Enable static rendering
setRequestLocale(locale)

const [gfissues] = await loadData()
let gfissues: GHIssue[] = []
try {
gfissues = (await getGFIs()) ?? []
} catch (error) {
console.warn("Failed to fetch GFIs for slug page:", error)
}

const slug = slugArray.join("/")

Expand Down
28 changes: 16 additions & 12 deletions app/[locale]/apps/[application]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { Tag } from "@/components/ui/tag"

import { APP_TAG_VARIANTS } from "@/lib/utils/apps"
import { getAppPageContributorInfo } from "@/lib/utils/contributors"
import { dataLoader } from "@/lib/utils/data/dataLoader"
import { isValidDate } from "@/lib/utils/date"
import { getMetadata } from "@/lib/utils/metadata"
import {
Expand All @@ -42,19 +41,12 @@ import {
import { slugify } from "@/lib/utils/url"
import { formatStringList } from "@/lib/utils/wallets"

import { BASE_TIME_UNIT } from "@/lib/constants"

import AppCard from "../_components/AppCard"

import ScreenshotSwiper from "./_components/ScreenshotSwiper"
import AppsAppJsonLD from "./page-jsonld"

import { fetchApps } from "@/lib/api/fetchApps"

// 24 hours
const REVALIDATE_TIME = BASE_TIME_UNIT * 24

const loadData = dataLoader([["appsData", fetchApps]], REVALIDATE_TIME * 1000)
import { getAppsData } from "@/lib/data"

const Page = async ({
params,
Expand All @@ -72,8 +64,14 @@ const Page = async ({
const requiredNamespaces = getRequiredNamespacesForPage("/apps")
const messages = pick(allMessages, requiredNamespaces)

// const [application] = application
const [appsData] = await loadData()
// Fetch apps data using the new data-layer function (already cached)
const appsData = await getAppsData()

// Handle null case - throw error if required data is missing
if (!appsData) {
throw new Error("Failed to fetch apps data")
}

const app = Object.values(appsData)
.flat()
.find((app) => slugify(app.name) === application)!
Expand Down Expand Up @@ -394,7 +392,13 @@ export async function generateMetadata({
}) {
const { locale, application } = params

const [appsData] = await loadData()
// Fetch apps data using the new data-layer function (already cached)
const appsData = await getAppsData()

// Handle null case - throw error if required data is missing
if (!appsData) {
throw new Error("Failed to fetch apps data")
}

const app = Object.values(appsData)
.flat()
Expand Down
18 changes: 8 additions & 10 deletions app/[locale]/apps/categories/[catetgoryName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,24 @@ import TabNav from "@/components/ui/TabNav"

import { getHighlightedApps } from "@/lib/utils/apps"
import { getAppPageContributorInfo } from "@/lib/utils/contributors"
import { dataLoader } from "@/lib/utils/data/dataLoader"
import { getMetadata } from "@/lib/utils/metadata"
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"

import { appsCategories } from "@/data/apps/categories"

import { BASE_TIME_UNIT } from "@/lib/constants"

import AppsHighlight from "../../_components/AppsHighlight"
import AppsTable from "../../_components/AppsTable"
import SuggestAnApp from "../../_components/SuggestAnApp"

import AppsCategoryJsonLD from "./page-jsonld"

import { fetchApps } from "@/lib/api/fetchApps"
import { getAppsData } from "@/lib/data"

const VALID_CATEGORIES = Object.values(AppCategoryEnum)

const isValidCategory = (category: string): category is AppCategoryEnum =>
VALID_CATEGORIES.includes(category as AppCategoryEnum)

// 24 hours
const REVALIDATE_TIME = BASE_TIME_UNIT * 24

const loadData = dataLoader([["appsData", fetchApps]], REVALIDATE_TIME * 1000)

const Page = async ({
params,
}: {
Expand All @@ -63,7 +55,13 @@ const Page = async ({
const { locale, catetgoryName } = params
setRequestLocale(locale)

const [appsData] = await loadData()
// Fetch apps data using the new data-layer function (already cached)
const appsData = await getAppsData()

// Handle null case - throw error if required data is missing
if (!appsData) {
throw new Error("Failed to fetch apps data")
}

const t = await getTranslations({ locale, namespace: "page-apps" })

Expand Down
31 changes: 14 additions & 17 deletions app/[locale]/apps/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,38 @@ import SubpageCard from "@/components/SubpageCard"

import { getDiscoverApps, getHighlightedApps } from "@/lib/utils/apps"
import { getAppPageContributorInfo } from "@/lib/utils/contributors"
import { dataLoader } from "@/lib/utils/data/dataLoader"
import { getMetadata } from "@/lib/utils/metadata"
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"

import { appsCategories } from "@/data/apps/categories"

import { BASE_TIME_UNIT } from "@/lib/constants"

import AppCard from "./_components/AppCard"
import AppsHighlight from "./_components/AppsHighlight"
import CommunityPicks from "./_components/CommunityPicks"
import SuggestAnApp from "./_components/SuggestAnApp"
import TopApps from "./_components/TopApps"
import AppsJsonLD from "./page-jsonld"

import { fetchApps } from "@/lib/api/fetchApps"
import { fetchCommunityPicks } from "@/lib/api/fetchCommunityPicks"

// 24 hours
const REVALIDATE_TIME = BASE_TIME_UNIT * 24

const loadData = dataLoader(
[
["appsData", fetchApps],
["communityPicks", fetchCommunityPicks],
],
REVALIDATE_TIME * 1000
)
import { getAppsData, getCommunityPicks } from "@/lib/data"

const Page = async ({ params }: { params: PageParams }) => {
const { locale } = params

setRequestLocale(locale)

const [appsData, communityPicks] = await loadData()
// Fetch data using the new data-layer functions (already cached)
const [appsData, communityPicks] = await Promise.all([
getAppsData(),
getCommunityPicks(),
])

// Handle null cases - throw error if required data is missing
if (!appsData) {
throw new Error("Failed to fetch apps data")
}
if (!communityPicks) {
throw new Error("Failed to fetch community picks data")
}

// Get 3 random highlighted apps
const highlightedApps = getHighlightedApps(appsData, 3)
Expand Down
28 changes: 21 additions & 7 deletions app/[locale]/developers/local-environment/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,43 @@ import {
} from "next-intl/server"

import type { CommitHistory, Lang, PageParams } from "@/lib/types"
import type { Framework } from "@/lib/interfaces"

import I18nProvider from "@/components/I18nProvider"

import { getAppPageContributorInfo } from "@/lib/utils/contributors"
import { dataLoader } from "@/lib/utils/data/dataLoader"
import { getMetadata } from "@/lib/utils/metadata"
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"

import { frameworksList } from "@/data/frameworks"

import LocalEnvironmentPage from "./_components/local-environment"
import LocalEnvironmentJsonLD from "./page-jsonld"

import { getLocalEnvironmentFrameworkData } from "@/lib/api/ghRepoData"

const loadData = dataLoader([
["frameworksListData", getLocalEnvironmentFrameworkData],
])
import { getGithubRepoData } from "@/lib/data"

const Page = async ({ params }: { params: PageParams }) => {
const { locale } = params

setRequestLocale(locale)

const [frameworksListData] = await loadData()
// Fetch GitHub repo data using the new data-layer function (already cached)
const githubRepoData = await getGithubRepoData()

// Handle null case - throw error if required data is missing
if (!githubRepoData) {
throw new Error("Failed to fetch GitHub repo data")
}

// Merge static framework data with GitHub repo data
const frameworksListData: Framework[] = frameworksList.map((framework) => {
const repoData = githubRepoData[framework.githubUrl]
return {
...framework,
starCount: repoData?.starCount,
languages: repoData?.languages?.slice(0, 2), // Limit to first 2 languages
}
})

// Get i18n messages
const allMessages = await getMessages({ locale })
Expand Down
Loading