Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(pricing): add launch discount banner and localization support (#44)

Corentin Thomasset53a1061017c8
diff --git a/package.json b/package.json
index 6501e596..28e8efe7 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"@astrojs/rss": "^4.0.11",
"@astrojs/sitemap": "^3.3.0",
"@branchlet/core": "^1.0.0",
+ "@corentinth/chisels": "^2.0.2",
"astro": "^5.7.2",
"astro-capo": "^0.0.1",
"astro-expressive-code": "^0.41.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index cb582e14..36d1339f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -23,6 +23,9 @@ importers:
'@branchlet/core':
specifier: ^1.0.0
version: 1.0.0
+ '@corentinth/chisels':
+ specifier: ^2.0.2
+ version: 2.0.2
astro:
specifier: ^5.7.2
@@ -284,6 +287,9 @@ packages:
'@cloudflare/[email protected]':
resolution: {integrity: sha512-gQpih+pbq3sP4uXltUeCSbPgZxTNp2gQd8639SaIbQMwgA6oJNHLhIART1fWy6DQACngiRzDVULA2x0ohmkGTQ==}
+ '@corentinth/[email protected]':
+ resolution: {integrity: sha512-PJh8IethKwqHjdyOXLl255UkY2GXqKrXnHmlj+sP0HJ1+9LNtXfUnushhrU3sgNikIkC3BPTgEtwBntq2clCMA==}
+
'@cspotcode/[email protected]':
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
engines: {node: '>=12'}
@@ -4614,6 +4620,8 @@ snapshots:
'@cloudflare/[email protected]': {}
+ '@corentinth/[email protected]': {}
+
'@cspotcode/[email protected]':
dependencies:
'@jridgewell/trace-mapping': 0.3.9
diff --git a/src/components/Footer.astro b/src/components/Footer.astro
index 5613dc62..ad9610a6 100644
--- a/src/components/Footer.astro
+++ b/src/components/Footer.astro
@@ -1,5 +1,5 @@
---
-import { useI18n } from '../i18n/i18n';
+import { buildLocalizedPath, useI18n } from '../i18n/i18n';
import { cn } from '../utils/cn';
import LanguagePicker from './LanguagePicker.astro';
@@ -39,6 +39,10 @@ const sections: {
{
title: t('footer.section.papra'),
links: [
+ {
+ label: t('footer.link.pricing'),
+ url: buildLocalizedPath({ locale: Astro.currentLocale, path: '/pricing' }),
+ },
{
label: t('footer.link.blog'),
url: '/blog',
@@ -109,7 +113,7 @@ const sections: {
},
{
label: t('footer.link.contact'),
- url: '/contact',
+ url: buildLocalizedPath({ locale: Astro.currentLocale, path: '/contact' }),
},
],
},
diff --git a/src/components/Header.astro b/src/components/Header.astro
index ca9869ea..e54e6e29 100644
--- a/src/components/Header.astro
+++ b/src/components/Header.astro
@@ -1,6 +1,6 @@
---
import { config, requestEarlyAccessLink } from '../app.config';
-import { useI18n } from '../i18n/i18n';
+import { buildLocalizedPath, useI18n } from '../i18n/i18n';
import { cn } from '../utils/cn';
const { t } = useI18n({ locale: Astro.currentLocale });
@@ -44,7 +44,7 @@ const navigation = [
? [
{
name: t('nav.pricing'),
- url: '/pricing',
+ url: buildLocalizedPath({ locale: Astro.currentLocale, path: '/pricing' }),
},
]
: []),
diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts
index 62719bb4..7676a8db 100644
--- a/src/i18n/i18n.ts
+++ b/src/i18n/i18n.ts
@@ -1,5 +1,6 @@
import type { TranslationsDictionary } from './i18n.types';
import { createBranchlet } from '@branchlet/core';
+import { joinUrlPaths } from '@corentinth/chisels';
import { translations } from '../locales/index';
import { DEFAULT_LOCALE, LOCALES } from './i18n.constants';
@@ -59,3 +60,7 @@ export function getPathWithoutLocale(url: URL | string) {
return pathname;
}
+
+export function buildLocalizedPath({ locale = DEFAULT_LOCALE, path }: { locale?: string; path: string }) {
+ return `/${joinUrlPaths(locale, path)}`;
+}
diff --git a/src/locales/en.ts b/src/locales/en.ts
index b45f0bf6..0bd0d866 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -72,6 +72,7 @@ export const translations = {
// Footer - Papra links
'footer.link.blog': 'Blog',
+ 'footer.link.pricing': 'Pricing',
'footer.link.demo-app': 'Demo app',
'footer.link.documentation': 'Documentation',
'footer.link.self-host': 'Self-host',
@@ -228,6 +229,8 @@ export const translations = {
// Pricing Page - Final CTA
'pricing.final-cta.title': 'Trusted by homes, startups, and enterprises of all sizes.',
'pricing.final-cta.button': 'Get started',
+ 'pricing.discount-banner.title': 'Launch Special: Get 50% off lifetime',
+ 'pricing.discount-banner.description': 'Get 50% off forever when you upgrade your organization to any paid plan during our launch period. This offer expires on 31 December 2025!',
// Contact Page
'contact.title': 'Contact',
diff --git a/src/locales/fr.ts b/src/locales/fr.ts
index b04b7959..1eb2a36a 100644
--- a/src/locales/fr.ts
+++ b/src/locales/fr.ts
@@ -74,6 +74,7 @@ export const translations: Partial<TranslationsDictionary> = {
// Footer - Papra links
'footer.link.blog': 'Blog',
+ 'footer.link.pricing': 'Tarifs',
'footer.link.demo-app': 'Application démo',
'footer.link.documentation': 'Documentation',
'footer.link.self-host': 'Auto-hébergement',
@@ -230,6 +231,8 @@ export const translations: Partial<TranslationsDictionary> = {
// Pricing Page - Final CTA
'pricing.final-cta.title': 'Ils nous font confiance : particuliers, startups et entreprises.',
'pricing.final-cta.button': 'Commencer',
+ 'pricing.discount-banner.title': 'Offre de Lancement : -50% à vie',
+ 'pricing.discount-banner.description': 'Bénéficiez de 50% de réduction à vie en passant vos organisations à n\'importe quel plan payant pendant notre période de lancement. Cette offre expire le 31 décembre 2025 !',
// Contact Page
'contact.title': 'Contact',
diff --git a/src/pages/[locale]/pricing.astro b/src/pages/[locale]/pricing.astro
index b42e20fc..65d6df0f 100644
--- a/src/pages/[locale]/pricing.astro
+++ b/src/pages/[locale]/pricing.astro
@@ -107,6 +107,26 @@ const plans: Plan[] = [
</p>
</div>
+ {discount.enabled && (
+ <div class="mb-8 bg-gradient-to-r from-primary/20 to-primary/2 border border-primary/30 rounded-lg p-4 flex-shrink-0">
+ <div class="flex items-center gap-4">
+ <div class="p-2.5 bg-primary/20 rounded-lg border border-primary/30 flex-shrink-0">
+ <div class="i-tabler-gift size-6 text-primary"></div>
+ </div>
+ <div class="flex-1">
+ <div class="flex items-center gap-2">
+ <h4 class="text-base font-semibold text-foreground">{t('pricing.discount-banner.title')}</h4>
+ <div class="px-2 py-0.5 bg-primary text-primary-foreground text-xs font-bold rounded-md">
+ {`-${discount.percentage}%`}
+ </div>
+ </div>
+ <p class="text-sm text-muted-foreground mb-1" set:html={t('pricing.discount-banner.description')} />
+ </div>
+ </div>
+ </div>
+
+ )}
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
{
plans.map(plan => (