Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rishi-raj-jain committed Oct 8, 2024
1 parent f3385c7 commit 4a7cd53
Show file tree
Hide file tree
Showing 24 changed files with 119 additions and 143 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion generate_blog_translations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ for (const lang of languages) {
const tmp = await translateText(currentChunk, lang)
if (tmp) appendFileSync(destinationPath, tmp, 'utf8')
}
let translatedContent = await readFileSync(destinationPath, 'utf8')
let translatedContent = readFileSync(destinationPath, 'utf8')
codeBlocks.forEach((match, _) => {
translatedContent = translatedContent.replace('[[CODE_BLOCK]]', match[0])
})
Expand Down
2 changes: 1 addition & 1 deletion generate_plugin_translations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ for (const lang of languages) {
const tmp = await translateText(currentChunk, lang)
if (tmp) appendFileSync(destinationPath, tmp, 'utf8')
}
let translatedContent = await readFileSync(destinationPath, 'utf8')
let translatedContent = readFileSync(destinationPath, 'utf8')
codeBlocks.forEach((match, _) => {
translatedContent = translatedContent.replace('[[CODE_BLOCK]]', match[0])
})
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"setup:new:locale": "tsx setup_new_locale.tsx"
},
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/sitemap": "^3.1.6",
"@astrojs/starlight": "^0.27.1",
"@astrojs/vue": "^4.5.1",
Expand All @@ -32,6 +33,7 @@
"posthog-js": "^1.165.0",
"sharp": "^0.33.5",
"sitemap": "^8.0.0",
"typescript": "^5.6.2",
"vue": "^3.5.10",
"vue-sonner": "^1.2.1"
},
Expand Down
3 changes: 2 additions & 1 deletion public/sw.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
self.addEventListener('fetch', function (event) {
event.respondWith(fetch(event.request))
})
self.addEventListener('install', (event) => {

self.addEventListener('install', () => {
self.skipWaiting()
})
18 changes: 6 additions & 12 deletions src/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { openMessenger } from '@/services/bento'
import { locales, type Locales } from '@/services/locale'
import translations from '@/services/translations'
const isOpen = ref(false)
const currentPath = ref('')
const year = new Date().getFullYear()
const config = useRuntimeConfig()
const brand = config.public.brand
const year = new Date().getFullYear()
const props = defineProps<{
locale: Locales
}>()
const isOpen = ref(false)
const toggleDropdown = () => {
isOpen.value = !isOpen.value
}
Expand All @@ -32,7 +32,8 @@ const statusChecker = async () => {
const response = await fetch('/status.json')
systemStatus.value = await response.json()
} catch (error) {
console.error('Error fetching status:', error)
console.error('Error fetching Capgo status:')
console.log(error)
}
}
Expand All @@ -41,9 +42,8 @@ onMounted(() => {
statusChecker()
window.addEventListener('hashchange', decidePath)
})
onUnmounted(() => {
window.removeEventListener('hashchange', decidePath)
})
onUnmounted(() => window.removeEventListener('hashchange', decidePath))
const navigation = {
solutions: [
Expand All @@ -60,11 +60,6 @@ const navigation = {
target: '_blank',
},
{ name: translations['top_app_by_framework'][props.locale], href: getRelativeLocaleUrl(props.locale, 'top_app') },
// { name: 'Top cordova app', href: '/top_cordova_app/' },
// { name: 'Top react native app', href: '/top_react_native_app/' },
// { name: 'Top flutter app', href: '/top_flutter_app/' },
// { name: 'Top kotlin app', href: '/top_kotlin_app/' },
// { name: 'Insights', href: '#' },
],
support: [
{
Expand Down Expand Up @@ -109,7 +104,6 @@ const navigation = {
},
],
legal: [
// { name: 'Claim', href: '#' },
{ name: translations['privacy'][props.locale], href: getRelativeLocaleUrl(props.locale, 'privacy'), rel: 'nofollow' },
{ name: translations['support_policy'][props.locale], href: getRelativeLocaleUrl(props.locale, 'support-policy'), rel: 'nofollow' },
{ name: translations['sla'][props.locale], href: getRelativeLocaleUrl(props.locale, 'sla'), rel: 'nofollow' },
Expand Down
3 changes: 1 addition & 2 deletions src/components/SEO.astro
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,4 @@ const makeFontPath = (name: string) => join(process.cwd(), 'public', 'fonts', na
<meta property="twitter:app:id:googleplay" content="ee.forgr.capgo" />
<meta property="twitter:app:name:googleplay" content="ee.forgr.capgo" />

<!-- @ts-ignore -->
<script hid="seo-schema-graph" type="application/ld+json" set:html={JSON.stringify(ldJSON)} />
<script is:inline hid="seo-schema-graph" type="application/ld+json" set:html={JSON.stringify(ldJSON)} />
30 changes: 11 additions & 19 deletions src/components/pricing/Calculator.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { Locales } from '@/services/locale'
import { roundNumber } from '@/services/misc'
import translations from '@/services/translations'
import type { Database } from '@/types/supabase.types'
import { computed, ref } from 'vue'
Expand Down Expand Up @@ -27,31 +28,27 @@ const props = defineProps({
},
})
const payg = props.pricing.find((plan) => plan.name === 'Pay as you go')!
const solo = props.pricing.find((plan) => plan.name === 'Solo')!
const maker = props.pricing.find((plan) => plan.name === 'Maker')!
const team = props.pricing.find((plan) => plan.name === 'Team')!
const maker = props.pricing.find((plan) => plan.name === 'Maker')!
const payg = props.pricing.find((plan) => plan.name === 'Pay as you go')!
const basePrice = payg.price_m
const mau = ref(maker.mau)
const updatesByMonth = ref(5)
const updatesSize = ref(4)
const updatesByMonth = ref(5)
const updates = computed(() => {
return mau.value * updatesByMonth.value
})
const storage = computed(() => {
return (updatesByMonth.value * updatesSize.value * 12) / 1000
})
const bandwidth = computed(() => {
return (updates.value * updatesSize.value) / 1000
})
const updates = computed(() => mau.value * updatesByMonth.value)
const bandwidth = computed(() => (updates.value * updatesSize.value) / 1000)
const storage = computed(() => (updatesByMonth.value * updatesSize.value * 12) / 1000)
const suggestion = computed(() => {
if (mau.value <= solo.mau && storage.value <= solo.storage && bandwidth.value <= solo.bandwidth) return 'Solo'
else if (mau.value <= maker.mau && storage.value <= maker.storage && bandwidth.value <= maker.bandwidth) return 'Maker'
else if (mau.value <= team.mau && storage.value <= team.storage && bandwidth.value <= team.bandwidth) return 'Team'
else return 'Pay as you go'
return 'Pay as you go'
})
function suggestionClick() {
if (suggestion.value === 'Pay as you go') {
window.scrollTo({
Expand All @@ -65,20 +62,15 @@ function suggestionClick() {
})
}
}
const basePrice = payg.price_m
const totalPrice = computed(() => {
const mauPrice = mau.value > props.paygBase.mau ? (mau.value - props.paygBase.mau) * props.paygUnits.mau : 0
const storagePrice = storage.value > props.paygBase.storage ? (storage.value - props.paygBase.storage) * props.paygUnits.storage : 0
const bandwidthPrice = bandwidth.value > props.paygBase.bandwidth ? (bandwidth.value - props.paygBase.bandwidth) * props.paygUnits.bandwidth : 0
const sum = mauPrice + storagePrice + bandwidthPrice
if (sum > 0) return roundNumber(basePrice + sum) * (props.yearly ? 12 : 1)
else return (suggestion.value ? roundNumber(props.pricing.find((plan) => plan.name === suggestion.value)!.price_m) : basePrice) * (props.yearly ? 12 : 1)
return (suggestion.value ? roundNumber(props.pricing.find((plan) => plan.name === suggestion.value)!.price_m) : basePrice) * (props.yearly ? 12 : 1)
})
function roundNumber(number: number) {
return Math.round(number * 100) / 100
}
</script>

<template>
Expand Down
13 changes: 1 addition & 12 deletions src/components/pricing/PayAsYouGo.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { Locales } from '@/services/locale'
import { numberWithSpaces, toTb, updateCalc } from '@/services/misc'
import translations from '@/services/translations'
import { getRelativeLocaleUrl } from 'astro:i18n'
Expand All @@ -17,18 +18,6 @@ const props = defineProps({
required: true,
},
})
function toTb(value: number) {
return (value / 1000).toFixed(2).toLocaleString()
}
function numberWithSpaces(x: number) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ')
}
function updateCalc(plan: any) {
return plan.mau * 5
}
</script>

<template>
Expand Down
11 changes: 2 additions & 9 deletions src/components/pricing/Plans.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Locales } from '@/services/locale'
import translations from '@/services/translations'
import type { Database } from '@/types/supabase.types'
import { getRelativeLocaleUrl } from 'astro:i18n'
import { numberWithSpaces, updateCalc } from '@/services/misc'
const props = defineProps({
pricing: {
Expand All @@ -19,15 +20,6 @@ const props = defineProps({
},
})
function numberWithSpaces(x: number) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ')
}
function updateCalc(plan: Database['public']['Tables']['plans']['Row']) {
// return aprox number of updates per month
return plan.mau * 5
}
function descToText(desc: string) {
switch (desc) {
case 'plan.free.desc':
Expand All @@ -42,6 +34,7 @@ function descToText(desc: string) {
return desc
}
}
function descToEmoji(desc: string) {
switch (desc) {
case 'plan.free.desc':
Expand Down
6 changes: 3 additions & 3 deletions src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ const blogDescription = 'The best articles to enhance your Capacitor app. Do mor
function getUrl(branch = ''): string {
if (branch === 'local') return `http://${getRightKey(branch, 'base_domain')}`
else if (branch === 'development') return `https://${getRightKey(branch, 'base_domain')}`
else return `https://${getRightKey('prod', 'base_domain')}`
return `https://${getRightKey('prod', 'base_domain')}`
}

function getApiUrl(branch = ''): string {
if (branch === 'local') return `http://api.${getRightKey(branch, 'base_domain')}`
else if (branch === 'development') return `https:///api.${getRightKey(branch, 'base_domain')}`
else return `https:///api.${getRightKey('prod', 'base_domain')}`
return `https:///api.${getRightKey('prod', 'base_domain')}`
}

export function baseDomain(branch = '') {
if (branch) return getRightKey(branch, 'base_domain')
else return getRightKey('prod', 'base_domain')
return getRightKey('prod', 'base_domain')
}

export function formatTime(s: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const pageLocale = (Astro.currentLocale || defaultLocale) as Locales
/>
)
}
<script defer data-website-id="66bcb7fa4038d5b1e5ea89eb" data-domain="capgo.app" src="https://datafa.st/js/script.js"></script>
<script is:inline defer data-website-id="66bcb7fa4038d5b1e5ea89eb" data-domain="capgo.app" src="https://datafa.st/js/script.js"></script>
{
!isLocalhost && (
<script>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/fr/plugins/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function getStaticPaths() {
.then((res) => {
if (res) plugins[index].npmDownloads = res.downloads
})
.catch((e) => {}),
.catch(() => {}),
)
// Fetch npm package details to get npm modified
const registryNpmApiUrl = `https://registry.npmjs.org/${item.name}`
Expand All @@ -52,7 +52,7 @@ export async function getStaticPaths() {
plugins[index].dateModified = res.time.modified
}
})
.catch((e) => {}),
.catch(() => {}),
)
// Extract the GitHub repository owner and name from the URL
const githubUrlParts = item.href.split('/')
Expand All @@ -68,7 +68,7 @@ export async function getStaticPaths() {
plugins[index].githubStars = res.stargazers_count
}
})
.catch((e) => {}),
.catch(() => {}),
)
// Update the item with fetched data
const readmeApiUrl = `https://api.github.com/repos/${githubOwner}/${githubRepo}/readme`
Expand All @@ -82,7 +82,7 @@ export async function getStaticPaths() {
else plugins[index].readme = tmp
}
})
.catch((e) => {}),
.catch(() => {}),
)
}
await Promise.all(promises)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/fr/sponsors.json.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { APIRoute } from 'astro'

export const GET: APIRoute = async ({ params, request }) => {
export const GET: APIRoute = async () => {
// remove isActive if you also want to include past sponsors
const query = `
query {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/plugins/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
.then((res) => {
if (res) plugins[index].npmDownloads = res.downloads
})
.catch((e) => {}),
.catch(() => {}),
)
// Fetch npm package details to get npm modified
const registryNpmApiUrl = `https://registry.npmjs.org/${item.name}`
Expand All @@ -53,7 +53,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
plugins[index].dateModified = res.time.modified
}
})
.catch((e) => {}),
.catch(() => {}),
)
// Extract the GitHub repository owner and name from the URL
const githubUrlParts = item.href.split('/')
Expand All @@ -69,7 +69,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
plugins[index].githubStars = res.stargazers_count
}
})
.catch((e) => {}),
.catch(() => {}),
)
// Update the item with fetched data
const readmeApiUrl = `https://api.github.com/repos/${githubOwner}/${githubRepo}/readme`
Expand All @@ -83,7 +83,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
else plugins[index].readme = tmp
}
})
.catch((e) => {}),
.catch(() => {}),
)
}
await Promise.all(promises)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/sponsors.json.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { APIRoute } from 'astro'

export const GET: APIRoute = async ({ params, request }) => {
export const GET: APIRoute = async () => {
// remove isActive if you also want to include past sponsors
const query = `
query {
Expand Down
2 changes: 1 addition & 1 deletion src/services/bento.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function pushEvent(nameEvent: string): void {
}

export function setUser(
uuid: string,
_: string,
data: {
nickname?: string
phone?: string
Expand Down
10 changes: 9 additions & 1 deletion src/services/misc.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
export function shortNumber(number: number) {
export const shortNumber = (number: number) => {
if (number > 1000000000) return `${(number / 1000000).toFixed(1)}B`
if (number > 1000000) return `${(number / 1000000).toFixed(1)}M`
if (number > 1000) return `${(number / 1000).toFixed(1)}k`
return `${number}`
}

export const renameCat = (text: string) => text.replaceAll('_', ' ')

export const updateCalc = (plan: any) => plan.mau * 5

export const numberWithSpaces = (x: number) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ')

export const toTb = (value: number) => (value / 1000).toFixed(2).toLocaleString()

export const roundNumber = (number: number) => Math.round(number * 100) / 100
Loading

0 comments on commit 4a7cd53

Please sign in to comment.