diff --git a/site/build.gradle.kts b/site/build.gradle.kts index 5c2fe75..9fb4b67 100644 --- a/site/build.gradle.kts +++ b/site/build.gradle.kts @@ -159,4 +159,55 @@ kotlin { } } +// For SEO we will have to use unique urls for each page +// Here we will use code generator to generate unique pages that redirect to the original pages +val langs = listOf("ar") +val pages = listOf("download_mobile_app", "privacy_policy") + +val generateLanguaguesPagesTask = tasks.register("generateLanguaguesPages") { + group = "net.freshplatform.alrayada_landing_page" + + doLast { + val pagesDirectory = project.file("src/jsMain/kotlin/net/freshplatform/alrayada_landing_page") + langs.forEach { lang -> + pages.forEach { page -> + + pagesDirectory.resolve("pages/$lang/${page}/Index.kt").apply { + parentFile.mkdirs() + writeText(""" + package ${group}.pages.ar.${page} + + import androidx.compose.runtime.Composable + import com.varabyte.kobweb.core.Page + import com.varabyte.kobweb.core.rememberPageContext + + @Composable + @Page + fun PrivacyPolicyPage_${lang}() { + rememberPageContext().router.navigateTo("/${page}/?lang=${lang}") + } + """.trimIndent()) + } + } + + pagesDirectory.resolve("pages/$lang/Index.kt").apply { + parentFile.mkdirs() + writeText(""" + package ${group}.pages.ar + + import androidx.compose.runtime.Composable + import com.varabyte.kobweb.core.Page + import com.varabyte.kobweb.core.rememberPageContext + + @Composable + @Page + fun PrivacyPolicyPage_${lang}() { + rememberPageContext().router.navigateTo("/?lang=${lang}") + } + """.trimIndent()) + } + + } + } +} \ No newline at end of file diff --git a/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/core/router/AppRouter.kt b/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/core/router/AppRouter.kt index 7c67d27..6a9f61f 100644 --- a/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/core/router/AppRouter.kt +++ b/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/core/router/AppRouter.kt @@ -1,8 +1,7 @@ package net.freshplatform.alrayada_landing_page.core.router object AppRouter { - // Unfortunately we can't use those in the pages routeOverride, even though it's a constant in compile time - const val HOME = "" + // Unfortunately, we can't use those in the pages routeOverride, even though it's a constant in compile time const val PRIVACY_POLICY = "/privacy_policy" const val DOWNLOAD_MOBILE_APP = "/download_mobile_app" } \ No newline at end of file diff --git a/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/Index.kt b/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/Index.kt index e8c0273..415d25a 100644 --- a/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/Index.kt +++ b/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/Index.kt @@ -6,6 +6,6 @@ import com.varabyte.kobweb.core.rememberPageContext @Composable @Page -fun HomePage_Arabic() { +fun PrivacyPolicyPage_ar() { rememberPageContext().router.navigateTo("/?lang=ar") } \ No newline at end of file diff --git a/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/download_mobile_app/Index.kt b/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/download_mobile_app/Index.kt index 63be0ee..e643e23 100644 --- a/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/download_mobile_app/Index.kt +++ b/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/download_mobile_app/Index.kt @@ -1,12 +1,11 @@ package net.freshplatform.alrayada_landing_page.pages.ar.download_mobile_app import androidx.compose.runtime.Composable -import net.freshplatform.alrayada_landing_page.core.router.AppRouter import com.varabyte.kobweb.core.Page import com.varabyte.kobweb.core.rememberPageContext @Composable @Page -fun DownloadMobileAppPage_Arabic() { - rememberPageContext().router.navigateTo("${AppRouter.DOWNLOAD_MOBILE_APP}/?lang=ar") +fun PrivacyPolicyPage_ar() { + rememberPageContext().router.navigateTo("/download_mobile_app/?lang=ar") } \ No newline at end of file diff --git a/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/privacy_policy/Index.kt b/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/privacy_policy/Index.kt index 36b2ced..afd9354 100644 --- a/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/privacy_policy/Index.kt +++ b/site/src/jsMain/kotlin/net/freshplatform/alrayada_landing_page/pages/ar/privacy_policy/Index.kt @@ -1,12 +1,11 @@ package net.freshplatform.alrayada_landing_page.pages.ar.privacy_policy import androidx.compose.runtime.Composable -import net.freshplatform.alrayada_landing_page.core.router.AppRouter import com.varabyte.kobweb.core.Page import com.varabyte.kobweb.core.rememberPageContext @Composable @Page -fun PrivacyPolicyPage_Arabic() { - rememberPageContext().router.navigateTo("${AppRouter.PRIVACY_POLICY}/?lang=ar") +fun PrivacyPolicyPage_ar() { + rememberPageContext().router.navigateTo("/privacy_policy/?lang=ar") } \ No newline at end of file