mirror of
https://github.com/zen-browser/www.git
synced 2025-07-08 01:10:02 +02:00
chore(prettier): format fiels with prettier
This commit is contained in:
parent
193c159db5
commit
e068816f18
36 changed files with 1261 additions and 1256 deletions
|
@ -1,21 +1,21 @@
|
||||||
import tailwind from "@astrojs/tailwind";
|
import tailwind from '@astrojs/tailwind'
|
||||||
// @ts-check
|
// @ts-check
|
||||||
import { defineConfig } from "astro/config";
|
import { defineConfig } from 'astro/config'
|
||||||
|
|
||||||
import preact from "@astrojs/preact";
|
import preact from '@astrojs/preact'
|
||||||
|
|
||||||
import sitemap from "@astrojs/sitemap";
|
import sitemap from '@astrojs/sitemap'
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
integrations: [tailwind(), preact({ compat: true }), sitemap({})],
|
integrations: [tailwind(), preact({ compat: true }), sitemap()],
|
||||||
site: "https://zen-browser.app",
|
site: 'https://zen-browser.app',
|
||||||
i18n: {
|
i18n: {
|
||||||
defaultLocale: "en",
|
defaultLocale: 'en',
|
||||||
locales: ["en"],
|
locales: ['en'],
|
||||||
routing: {
|
routing: {
|
||||||
fallbackType: "rewrite",
|
fallbackType: 'rewrite',
|
||||||
prefixDefaultLocale: false,
|
prefixDefaultLocale: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
---
|
---
|
||||||
import { ArrowLeft } from "lucide-astro";
|
import { ArrowLeft } from 'lucide-astro'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: {
|
routes: {
|
||||||
mods: { slug },
|
mods: { slug },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
import { getLocale, getPath } from "~/utils/i18n";
|
import { getLocale, getPath } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
const getLocalePath = getPath(locale);
|
const getLocalePath = getPath(locale)
|
||||||
const {
|
const {
|
||||||
class: className,
|
class: className,
|
||||||
isPrimary,
|
isPrimary,
|
||||||
|
@ -11,7 +11,7 @@ const {
|
||||||
href,
|
href,
|
||||||
id,
|
id,
|
||||||
extra,
|
extra,
|
||||||
} = Astro.props;
|
} = Astro.props
|
||||||
---
|
---
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
const { white, multiplier = 0.9, class: classList } = Astro.props;
|
const { white, multiplier = 0.9, class: classList } = Astro.props
|
||||||
const sizes = [216, 396, 576, 756];
|
const sizes = [216, 396, 576, 756]
|
||||||
const borderWidths = [20, 30, 40, 50];
|
const borderWidths = [20, 30, 40, 50]
|
||||||
---
|
---
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
---
|
---
|
||||||
import Image from "astro/components/Image.astro";
|
import Image from 'astro/components/Image.astro'
|
||||||
import { Check, Github } from "lucide-astro";
|
import { Check, Github } from 'lucide-astro'
|
||||||
import { motion } from "motion/react";
|
import { motion } from 'motion/react'
|
||||||
import { getTitleAnimation } from "~/animations";
|
import { getTitleAnimation } from '~/animations'
|
||||||
import ComImage from "~/assets/ComImage.png";
|
import ComImage from '~/assets/ComImage.png'
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: {
|
routes: {
|
||||||
index: { community },
|
index: { community },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<section
|
<section
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
---
|
---
|
||||||
import { motion } from "motion/react";
|
import { motion } from 'motion/react'
|
||||||
import { getTitleAnimation } from "~/animations";
|
import { getTitleAnimation } from '~/animations'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
|
|
||||||
import CompactModeVideo from "~/assets/CompactMode.webm";
|
import CompactModeVideo from '~/assets/CompactMode.webm'
|
||||||
import GlanceVideo from "~/assets/Glance.webm";
|
import GlanceVideo from '~/assets/Glance.webm'
|
||||||
import SplitViewsVideo from "~/assets/SplitViews.webm";
|
import SplitViewsVideo from '~/assets/SplitViews.webm'
|
||||||
import WorkspacesVideo from "~/assets/Workspaces.webm";
|
import WorkspacesVideo from '~/assets/Workspaces.webm'
|
||||||
|
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
import Video from "./Video.astro";
|
import Video from './Video.astro'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: {
|
routes: {
|
||||||
index: { features },
|
index: { features },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
title1 = features.title1,
|
title1 = features.title1,
|
||||||
title2 = features.title2,
|
title2 = features.title2,
|
||||||
title3 = features.title3,
|
title3 = features.title3,
|
||||||
} = Astro.props;
|
} = Astro.props
|
||||||
|
|
||||||
const descriptions = Object.values(features.featureTabs).map(
|
const descriptions = Object.values(features.featureTabs).map(
|
||||||
(tab) => tab.description,
|
(tab) => tab.description,
|
||||||
);
|
)
|
||||||
---
|
---
|
||||||
|
|
||||||
<section
|
<section
|
||||||
|
@ -180,12 +180,12 @@ const descriptions = Object.values(features.featureTabs).map(
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const features = document.querySelectorAll(
|
const features = document.querySelectorAll(
|
||||||
'.feature, .feature-tab'
|
'.feature, .feature-tab',
|
||||||
) as NodeListOf<HTMLElement>
|
) as NodeListOf<HTMLElement>
|
||||||
|
|
||||||
// Set initial description
|
// Set initial description
|
||||||
const descriptionEl = document.querySelector(
|
const descriptionEl = document.querySelector(
|
||||||
'.feature-description'
|
'.feature-description',
|
||||||
) as HTMLDivElement
|
) as HTMLDivElement
|
||||||
const descriptions = descriptionEl?.dataset.descriptions?.split(',')
|
const descriptions = descriptionEl?.dataset.descriptions?.split(',')
|
||||||
if (descriptionEl && descriptions) {
|
if (descriptionEl && descriptions) {
|
||||||
|
@ -219,7 +219,7 @@ const descriptions = Object.values(features.featureTabs).map(
|
||||||
}
|
}
|
||||||
|
|
||||||
const videos = document.querySelectorAll(
|
const videos = document.querySelectorAll(
|
||||||
'.feature-video'
|
'.feature-video',
|
||||||
) as NodeListOf<HTMLVideoElement>
|
) as NodeListOf<HTMLVideoElement>
|
||||||
videos.forEach((vid, i) => {
|
videos.forEach((vid, i) => {
|
||||||
const yOffset = (i - index) * 20
|
const yOffset = (i - index) * 20
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
---
|
---
|
||||||
import { ArrowRight } from "lucide-astro";
|
import { ArrowRight } from 'lucide-astro'
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import Circles from "~/components/Circles.astro";
|
import Circles from '~/components/Circles.astro'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import SocialMediaStrip from "~/components/SocialMediaStrip.astro";
|
import SocialMediaStrip from '~/components/SocialMediaStrip.astro'
|
||||||
import { getLocale, getPath, getUI } from "~/utils/i18n";
|
import { getLocale, getPath, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
const getLocalePath = getPath(locale);
|
const getLocalePath = getPath(locale)
|
||||||
const {
|
const {
|
||||||
components: { footer },
|
components: { footer },
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<footer
|
<footer
|
||||||
|
@ -24,7 +24,9 @@ const {
|
||||||
class="w-full text-center lg:w-1/2 lg:text-left"
|
class="w-full text-center lg:w-1/2 lg:text-left"
|
||||||
aria-labelledby="footer-title"
|
aria-labelledby="footer-title"
|
||||||
>
|
>
|
||||||
<Description id="footer-title" class="!text-paper text-6xl font-bold">{footer.title}</Title>
|
<Description id="footer-title" class="text-6xl font-bold !text-paper"
|
||||||
|
>{footer.title}</Description
|
||||||
|
>
|
||||||
<Description class="mx-auto max-w-xl lg:mx-0">
|
<Description class="mx-auto max-w-xl lg:mx-0">
|
||||||
{footer.description}
|
{footer.description}
|
||||||
</Description>
|
</Description>
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
---
|
---
|
||||||
import { ArrowRight } from "lucide-astro";
|
import { ArrowRight } from 'lucide-astro'
|
||||||
import { motion } from "motion/react";
|
import { motion } from 'motion/react'
|
||||||
import { getTitleAnimation } from "~/animations";
|
import { getTitleAnimation } from '~/animations'
|
||||||
import HomePageVideo from "~/assets/HomePageVideo.webm";
|
import HomePageVideo from '~/assets/HomePageVideo.webm'
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import Title from "~/components/Title.astro";
|
import Title from '~/components/Title.astro'
|
||||||
import { getLocale, getPath, getUI } from "~/utils/i18n";
|
import { getLocale, getPath, getUI } from '~/utils/i18n'
|
||||||
import SocialMediaStrip from "./SocialMediaStrip.astro";
|
import SocialMediaStrip from './SocialMediaStrip.astro'
|
||||||
import Video from "./Video.astro";
|
import Video from './Video.astro'
|
||||||
|
|
||||||
let titleAnimationCounter = 0;
|
let titleAnimationCounter = 0
|
||||||
function getNewAnimationDelay() {
|
function getNewAnimationDelay() {
|
||||||
titleAnimationCounter++;
|
titleAnimationCounter++
|
||||||
return titleAnimationCounter * 0.15;
|
return titleAnimationCounter * 0.15
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHeroTitleAnimation() {
|
function getHeroTitleAnimation() {
|
||||||
return getTitleAnimation(getNewAnimationDelay());
|
return getTitleAnimation(getNewAnimationDelay())
|
||||||
}
|
}
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const getLocalePath = getPath(locale);
|
const getLocalePath = getPath(locale)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: {
|
routes: {
|
||||||
index: { hero },
|
index: { hero },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<header
|
<header
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
---
|
---
|
||||||
import { getLocale, getPath, getUI } from "~/utils/i18n";
|
import { getLocale, getPath, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
const getLocalePath = getPath(locale);
|
const getLocalePath = getPath(locale)
|
||||||
const {
|
const {
|
||||||
components: {
|
components: {
|
||||||
nav: { menu },
|
nav: { menu },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Hidden checkbox for menu toggle -->
|
<!-- Hidden checkbox for menu toggle -->
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
import { icon, library } from "@fortawesome/fontawesome-svg-core";
|
import { icon, library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import { faSort, faSortDown, faSortUp } from '@fortawesome/free-solid-svg-icons'
|
||||||
faSort,
|
import { useEffect, useState } from 'preact/hooks'
|
||||||
faSortDown,
|
import { useModsSearch } from '~/hooks/useModsSearch'
|
||||||
faSortUp,
|
import type { ZenTheme } from '~/mods'
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
import { type Locale, getUI } from '~/utils/i18n'
|
||||||
import { useEffect, useState } from "preact/hooks";
|
|
||||||
import { useModsSearch } from "~/hooks/useModsSearch";
|
|
||||||
import type { ZenTheme } from "~/mods";
|
|
||||||
import { type Locale, getUI } from "~/utils/i18n";
|
|
||||||
|
|
||||||
// Add icons to the library
|
// Add icons to the library
|
||||||
library.add(faSort, faSortUp, faSortDown);
|
library.add(faSort, faSortUp, faSortDown)
|
||||||
|
|
||||||
// Create icon objects
|
// Create icon objects
|
||||||
const defaultSortIcon = icon({ prefix: "fas", iconName: "sort" });
|
const defaultSortIcon = icon({ prefix: 'fas', iconName: 'sort' })
|
||||||
const ascSortIcon = icon({ prefix: "fas", iconName: "sort-up" });
|
const ascSortIcon = icon({ prefix: 'fas', iconName: 'sort-up' })
|
||||||
const descSortIcon = icon({ prefix: "fas", iconName: "sort-down" });
|
const descSortIcon = icon({ prefix: 'fas', iconName: 'sort-down' })
|
||||||
|
|
||||||
interface ModsListProps {
|
interface ModsListProps {
|
||||||
allMods: ZenTheme[];
|
allMods: ZenTheme[]
|
||||||
locale: Locale;
|
locale: Locale
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ModsList({ allMods, locale }: ModsListProps) {
|
export default function ModsList({ allMods, locale }: ModsListProps) {
|
||||||
|
@ -38,58 +34,58 @@ export default function ModsList({ allMods, locale }: ModsListProps) {
|
||||||
setLimit,
|
setLimit,
|
||||||
mods: paginatedMods,
|
mods: paginatedMods,
|
||||||
// searchParams,
|
// searchParams,
|
||||||
} = useModsSearch(allMods);
|
} = useModsSearch(allMods)
|
||||||
|
|
||||||
const [pageInput, setPageInput] = useState(page.toString());
|
const [pageInput, setPageInput] = useState(page.toString())
|
||||||
|
|
||||||
// Keep page input in sync with actual page
|
// Keep page input in sync with actual page
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPageInput(page.toString());
|
setPageInput(page.toString())
|
||||||
}, [page]);
|
}, [page])
|
||||||
|
|
||||||
function getSortIcon(state: "default" | "asc" | "desc") {
|
function getSortIcon(state: 'default' | 'asc' | 'desc') {
|
||||||
if (state === "asc") return ascSortIcon;
|
if (state === 'asc') return ascSortIcon
|
||||||
if (state === "desc") return descSortIcon;
|
if (state === 'desc') return descSortIcon
|
||||||
return defaultSortIcon;
|
return defaultSortIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSearch(e: Event) {
|
function handleSearch(e: Event) {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target as HTMLInputElement
|
||||||
setSearch(target.value);
|
setSearch(target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleLimitChange(e: Event) {
|
function handleLimitChange(e: Event) {
|
||||||
const target = e.target as HTMLSelectElement;
|
const target = e.target as HTMLSelectElement
|
||||||
setLimit(Number.parseInt(target.value, 10));
|
setLimit(Number.parseInt(target.value, 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePageSubmit(e: Event) {
|
function handlePageSubmit(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault()
|
||||||
const newPage = Number.parseInt(pageInput, 10);
|
const newPage = Number.parseInt(pageInput, 10)
|
||||||
if (!Number.isNaN(newPage) && newPage >= 1 && newPage <= totalPages) {
|
if (!Number.isNaN(newPage) && newPage >= 1 && newPage <= totalPages) {
|
||||||
setPage(newPage);
|
setPage(newPage)
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0)
|
||||||
} else {
|
} else {
|
||||||
setPageInput(page.toString());
|
setPageInput(page.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePageInputChange(e: Event) {
|
function handlePageInputChange(e: Event) {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target as HTMLInputElement
|
||||||
setPageInput(target.value);
|
setPageInput(target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigatePage(pageNum: number) {
|
function navigatePage(pageNum: number) {
|
||||||
setPage(pageNum);
|
setPage(pageNum)
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: { mods },
|
routes: { mods },
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
|
|
||||||
function renderPagination() {
|
function renderPagination() {
|
||||||
if (totalPages <= 1) return null;
|
if (totalPages <= 1) return null
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto mb-12 flex items-center justify-center gap-4 px-8">
|
<div className="mx-auto mb-12 flex items-center justify-center gap-4 px-8">
|
||||||
<button
|
<button
|
||||||
|
@ -97,14 +93,14 @@ export default function ModsList({ allMods, locale }: ModsListProps) {
|
||||||
onClick={() => navigatePage(page - 1)}
|
onClick={() => navigatePage(page - 1)}
|
||||||
className={`px-3 py-2 ${
|
className={`px-3 py-2 ${
|
||||||
page === 1
|
page === 1
|
||||||
? "pointer-events-none text-gray-400"
|
? 'pointer-events-none text-gray-400'
|
||||||
: "text-dark hover:text-gray-600"
|
: 'text-dark hover:text-gray-600'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<
|
<
|
||||||
</button>
|
</button>
|
||||||
<form onSubmit={handlePageSubmit} className="flex items-center gap-2">
|
<form onSubmit={handlePageSubmit} className="flex items-center gap-2">
|
||||||
{mods.pagination.pagination.split("{input}").map((value, index) => {
|
{mods.pagination.pagination.split('{input}').map((value, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
|
@ -114,15 +110,15 @@ export default function ModsList({ allMods, locale }: ModsListProps) {
|
||||||
className="w-16 rounded border border-dark bg-transparent px-2 py-1 text-center text-sm"
|
className="w-16 rounded border border-dark bg-transparent px-2 py-1 text-center text-sm"
|
||||||
aria-label="Page number"
|
aria-label="Page number"
|
||||||
/>
|
/>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
{value
|
{value
|
||||||
.replace("{totalPages}", totalPages.toString())
|
.replace('{totalPages}', totalPages.toString())
|
||||||
.replace("{totalItems}", totalItems.toString())}
|
.replace('{totalItems}', totalItems.toString())}
|
||||||
</span>
|
</span>
|
||||||
);
|
)
|
||||||
})}
|
})}
|
||||||
</form>
|
</form>
|
||||||
<button
|
<button
|
||||||
|
@ -130,14 +126,14 @@ export default function ModsList({ allMods, locale }: ModsListProps) {
|
||||||
onClick={() => navigatePage(page + 1)}
|
onClick={() => navigatePage(page + 1)}
|
||||||
className={`px-3 py-2 ${
|
className={`px-3 py-2 ${
|
||||||
page === totalPages
|
page === totalPages
|
||||||
? "pointer-events-none text-gray-400"
|
? 'pointer-events-none text-gray-400'
|
||||||
: "text-dark hover:text-gray-600"
|
: 'text-dark hover:text-gray-600'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -222,7 +218,7 @@ export default function ModsList({ allMods, locale }: ModsListProps) {
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-lg font-bold">
|
<h2 className="text-lg font-bold">
|
||||||
{mod.name}{" "}
|
{mod.name}{' '}
|
||||||
<span className="ml-1 text-sm font-normal">
|
<span className="ml-1 text-sm font-normal">
|
||||||
by @{mod.author}
|
by @{mod.author}
|
||||||
</span>
|
</span>
|
||||||
|
@ -241,5 +237,5 @@ export default function ModsList({ allMods, locale }: ModsListProps) {
|
||||||
|
|
||||||
{renderPagination()}
|
{renderPagination()}
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
---
|
---
|
||||||
import { Astronav, Dropdown, DropdownItems, MenuItems } from "astro-navbar";
|
import { Astronav, Dropdown, DropdownItems, MenuItems } from 'astro-navbar'
|
||||||
import { ArrowRight, ChevronDown, Download, Menu } from "lucide-astro";
|
import { ArrowRight, ChevronDown, Download, Menu } from 'lucide-astro'
|
||||||
import { motion } from "motion/react";
|
import { motion } from 'motion/react'
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import { getLocale, getPath, getUI } from "~/utils/i18n";
|
import { getLocale, getPath, getUI } from '~/utils/i18n'
|
||||||
import { getTitleAnimation } from "../animations.ts";
|
import { getTitleAnimation } from '../animations.ts'
|
||||||
import Logo from "./Logo.astro";
|
import Logo from './Logo.astro'
|
||||||
import MobileMenu from "./MobileMenu.astro";
|
import MobileMenu from './MobileMenu.astro'
|
||||||
import ThemeSwitch from "./ThemeSwitch.astro";
|
import ThemeSwitch from './ThemeSwitch.astro'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
const getLocalePath = getPath(locale);
|
const getLocalePath = getPath(locale)
|
||||||
const {
|
const {
|
||||||
components: {
|
components: {
|
||||||
nav: { brand, menu },
|
nav: { brand, menu },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Desktop Navigation -->
|
<!-- Desktop Navigation -->
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
---
|
---
|
||||||
import { Accordion, AccordionItem } from "free-astro-components";
|
import { Accordion, AccordionItem } from 'free-astro-components'
|
||||||
import { Info } from "lucide-astro";
|
import { Info } from 'lucide-astro'
|
||||||
|
|
||||||
import { releaseNotes as releaseNotesData } from "~/release-notes";
|
import { releaseNotes as releaseNotesData } from '~/release-notes'
|
||||||
import { getLocale, getPath, getUI } from "~/utils/i18n";
|
import { getLocale, getPath, getUI } from '~/utils/i18n'
|
||||||
import {
|
import {
|
||||||
type BreakingChange,
|
type BreakingChange,
|
||||||
type ReleaseNote,
|
type ReleaseNote,
|
||||||
getReleaseNoteFirefoxVersion,
|
getReleaseNoteFirefoxVersion,
|
||||||
} from "../release-notes";
|
} from '../release-notes'
|
||||||
export type Props = ReleaseNote;
|
export type Props = ReleaseNote
|
||||||
const { isTwilight, ...props } = Astro.props;
|
const { isTwilight, ...props } = Astro.props
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
const getLocalePath = getPath(locale);
|
const getLocalePath = getPath(locale)
|
||||||
const {
|
const {
|
||||||
routes: {
|
routes: {
|
||||||
releaseNotes: {
|
releaseNotes: {
|
||||||
components: { releaseNoteItem },
|
components: { releaseNoteItem },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
|
|
||||||
let date;
|
let date
|
||||||
if (props.date) {
|
if (props.date) {
|
||||||
const [day, month, year] = props.date.split("/");
|
const [day, month, year] = props.date.split('/')
|
||||||
date = new Date(Date.parse(`${year}-${month}-${day}`));
|
date = new Date(Date.parse(`${year}-${month}-${day}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
const ffVersion = getReleaseNoteFirefoxVersion(props);
|
const ffVersion = getReleaseNoteFirefoxVersion(props)
|
||||||
const currentReleaseIndex = releaseNotesData.findIndex(
|
const currentReleaseIndex = releaseNotesData.findIndex(
|
||||||
(releaseNote: ReleaseNote) => releaseNote.version === props.version,
|
(releaseNote: ReleaseNote) => releaseNote.version === props.version,
|
||||||
);
|
)
|
||||||
const prevReleaseNote = releaseNotesData[currentReleaseIndex + 1];
|
const prevReleaseNote = releaseNotesData[currentReleaseIndex + 1]
|
||||||
let compareLink = "";
|
let compareLink = ''
|
||||||
if (prevReleaseNote && !isTwilight) {
|
if (prevReleaseNote && !isTwilight) {
|
||||||
compareLink = `https://github.com/zen-browser/desktop/compare/${prevReleaseNote.version}...${props.version}`;
|
compareLink = `https://github.com/zen-browser/desktop/compare/${prevReleaseNote.version}...${props.version}`
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -62,7 +62,10 @@ if (prevReleaseNote && !isTwilight) {
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{releaseNoteItem.releaseChanges.replaceAll("{version}", props.version)}
|
{releaseNoteItem.releaseChanges.replaceAll(
|
||||||
|
'{version}',
|
||||||
|
props.version,
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -152,7 +155,7 @@ if (prevReleaseNote && !isTwilight) {
|
||||||
target="_blank"
|
target="_blank"
|
||||||
aria-label={releaseNoteItem.viewIssue.replace(
|
aria-label={releaseNoteItem.viewIssue.replace(
|
||||||
'{issue}',
|
'{issue}',
|
||||||
fix.issue
|
fix.issue,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
#{fix.issue}
|
#{fix.issue}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
---
|
---
|
||||||
const { gap = 4 } = Astro.props;
|
const { gap = 4 } = Astro.props
|
||||||
|
|
||||||
import { icon, library } from "@fortawesome/fontawesome-svg-core";
|
import { icon, library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
faBluesky,
|
faBluesky,
|
||||||
faGithub,
|
faGithub,
|
||||||
faMastodon,
|
faMastodon,
|
||||||
faReddit,
|
faReddit,
|
||||||
faXTwitter,
|
faXTwitter,
|
||||||
} from "@fortawesome/free-brands-svg-icons";
|
} from '@fortawesome/free-brands-svg-icons'
|
||||||
|
|
||||||
library.add(faMastodon, faBluesky, faGithub, faXTwitter, faReddit);
|
library.add(faMastodon, faBluesky, faGithub, faXTwitter, faReddit)
|
||||||
const Mastodon = icon({ prefix: "fab", iconName: "mastodon" });
|
const Mastodon = icon({ prefix: 'fab', iconName: 'mastodon' })
|
||||||
const Bluesky = icon({ prefix: "fab", iconName: "bluesky" });
|
const Bluesky = icon({ prefix: 'fab', iconName: 'bluesky' })
|
||||||
const Github = icon({ prefix: "fab", iconName: "github" });
|
const Github = icon({ prefix: 'fab', iconName: 'github' })
|
||||||
const XTwitter = icon({ prefix: "fab", iconName: "x-twitter" });
|
const XTwitter = icon({ prefix: 'fab', iconName: 'x-twitter' })
|
||||||
const Reddit = icon({ prefix: "fab", iconName: "reddit" });
|
const Reddit = icon({ prefix: 'fab', iconName: 'reddit' })
|
||||||
---
|
---
|
||||||
|
|
||||||
<ul class={`flex items-center opacity-80 gap-${gap}`}>
|
<ul class={`flex items-center opacity-80 gap-${gap}`}>
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
---
|
---
|
||||||
import { motion } from "motion/react";
|
import { motion } from 'motion/react'
|
||||||
import { getTitleAnimation } from "~/animations";
|
import { getTitleAnimation } from '~/animations'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
import tutaLogo from "~/assets/tuta-logo.png";
|
import tutaLogo from '~/assets/tuta-logo.png'
|
||||||
|
|
||||||
import Image from "astro/components/Image.astro";
|
import Image from 'astro/components/Image.astro'
|
||||||
const { showSponsors = true } = Astro.props;
|
const { showSponsors = true } = Astro.props
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: {
|
routes: {
|
||||||
index: { sponsors },
|
index: { sponsors },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<section id="sponsors" class:list={['mb-32 px-4', !showSponsors && 'hidden']}>
|
<section id="sponsors" class:list={['mb-32 px-4', !showSponsors && 'hidden']}>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
---
|
---
|
||||||
interface Props {
|
interface Props {
|
||||||
label?: string;
|
label?: string
|
||||||
className?: string;
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const { label, className = "" } = Astro.props;
|
const { label, className = '' } = Astro.props
|
||||||
---
|
---
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
const { class: className } = Astro.props;
|
const { class: className } = Astro.props
|
||||||
---
|
---
|
||||||
|
|
||||||
<h1 class:list={['title text-dark', className]}>
|
<h1 class:list={['title text-dark', className]}>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
const { src, class: className, ...rest } = Astro.props;
|
const { src, class: className, ...rest } = Astro.props
|
||||||
const type = src.split(".").pop() || "webm";
|
const type = src.split('.').pop() || 'webm'
|
||||||
---
|
---
|
||||||
|
|
||||||
<video
|
<video
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export const I18N = {
|
export const I18N = {
|
||||||
DEFAULT_LOCALE: "en",
|
DEFAULT_LOCALE: 'en',
|
||||||
LOCALES: [{ label: "English", value: "en" }],
|
LOCALES: [{ label: 'English', value: 'en' }],
|
||||||
} as const;
|
} as const
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { I18N } from "./i18n";
|
import { I18N } from './i18n'
|
||||||
|
|
||||||
export const CONSTANT = {
|
export const CONSTANT = {
|
||||||
I18N,
|
I18N,
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
import NotFound from "./[...locale]/404.astro";
|
import NotFound from './[...locale]/404.astro'
|
||||||
---
|
---
|
||||||
|
|
||||||
<NotFound />
|
<NotFound />
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
---
|
---
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import Title from "~/components/Title.astro";
|
import Title from '~/components/Title.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getLocale, getPath, getUI } from "~/utils/i18n";
|
import { getLocale, getPath, getUI } from '~/utils/i18n'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
const getLocalePath = getPath(locale);
|
const getLocalePath = getPath(locale)
|
||||||
const {
|
const {
|
||||||
routes: { notFound },
|
routes: { notFound },
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={notFound.title}>
|
<Layout title={notFound.title}>
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
---
|
---
|
||||||
import { ArrowRight } from "lucide-astro";
|
import { ArrowRight } from 'lucide-astro'
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
const {
|
const {
|
||||||
routes: { donate },
|
routes: { donate },
|
||||||
layout,
|
layout,
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={layout.donate.title} description={layout.donate.description}>
|
<Layout title={layout.donate.title} description={layout.donate.description}>
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
---
|
---
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import DownloadScript from "~/components/download/DownloadScript.astro";
|
import DownloadScript from '~/components/download/DownloadScript.astro'
|
||||||
import PlatformDownload from "~/components/download/PlatformDownload.astro";
|
import PlatformDownload from '~/components/download/PlatformDownload.astro'
|
||||||
import { getReleasesWithChecksums } from "~/components/download/release-data.astro";
|
import { getReleasesWithChecksums } from '~/components/download/release-data.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getChecksums } from "~/utils/githubChecksums";
|
import { getChecksums } from '~/utils/githubChecksums'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
import { icon, library } from "@fortawesome/fontawesome-svg-core";
|
import { icon, library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
faApple,
|
faApple,
|
||||||
faGithub,
|
faGithub,
|
||||||
faLinux,
|
faLinux,
|
||||||
faWindows,
|
faWindows,
|
||||||
} from "@fortawesome/free-brands-svg-icons";
|
} from '@fortawesome/free-brands-svg-icons'
|
||||||
import { ExternalLink, Lock } from "lucide-astro";
|
import { ExternalLink, Lock } from 'lucide-astro'
|
||||||
|
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
const {
|
const {
|
||||||
routes: { download },
|
routes: { download },
|
||||||
layout,
|
layout,
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
|
|
||||||
library.add(faWindows, faLinux, faApple, faGithub);
|
library.add(faWindows, faLinux, faApple, faGithub)
|
||||||
const windowsIcon = icon({ prefix: "fab", iconName: "windows" });
|
const windowsIcon = icon({ prefix: 'fab', iconName: 'windows' })
|
||||||
const linuxIcon = icon({ prefix: "fab", iconName: "linux" });
|
const linuxIcon = icon({ prefix: 'fab', iconName: 'linux' })
|
||||||
const appleIcon = icon({ prefix: "fab", iconName: "apple" });
|
const appleIcon = icon({ prefix: 'fab', iconName: 'apple' })
|
||||||
const githubIcon = icon({ prefix: "fab", iconName: "github" });
|
const githubIcon = icon({ prefix: 'fab', iconName: 'github' })
|
||||||
|
|
||||||
const checksums = await getChecksums();
|
const checksums = await getChecksums()
|
||||||
const releases = getReleasesWithChecksums(checksums);
|
const releases = getReleasesWithChecksums(checksums)
|
||||||
|
|
||||||
const platformNames = download.platformNames;
|
const platformNames = download.platformNames
|
||||||
const platformDescriptions = download.platformDescriptions;
|
const platformDescriptions = download.platformDescriptions
|
||||||
---
|
---
|
||||||
|
|
||||||
<DownloadScript />
|
<DownloadScript />
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import rss, { type RSSOptions } from "@astrojs/rss";
|
import rss, { type RSSOptions } from '@astrojs/rss'
|
||||||
import { releaseNotes } from "~/release-notes";
|
import { releaseNotes } from '~/release-notes'
|
||||||
import type { ReleaseNote } from "~/release-notes";
|
import type { ReleaseNote } from '~/release-notes'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
/** The default number of entries to include in the RSS feed. */
|
/** The default number of entries to include in the RSS feed. */
|
||||||
const RSS_ENTRY_LIMIT = 20;
|
const RSS_ENTRY_LIMIT = 20
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the GET request for the `feed.xml` endpoint.
|
* Handles the GET request for the `feed.xml` endpoint.
|
||||||
|
@ -15,11 +15,11 @@ export function GET(context: any) {
|
||||||
const latestDate =
|
const latestDate =
|
||||||
releaseNotes.length > 0
|
releaseNotes.length > 0
|
||||||
? formatRssDate(releaseNotes[0].date as string)
|
? formatRssDate(releaseNotes[0].date as string)
|
||||||
: new Date();
|
: new Date()
|
||||||
|
|
||||||
const rssData: RSSOptions = {
|
const rssData: RSSOptions = {
|
||||||
title: "Zen Browser Release Notes",
|
title: 'Zen Browser Release Notes',
|
||||||
description: "Release Notes for the Zen Browser",
|
description: 'Release Notes for the Zen Browser',
|
||||||
site: context.url,
|
site: context.url,
|
||||||
items: [],
|
items: [],
|
||||||
customData: `
|
customData: `
|
||||||
|
@ -33,7 +33,7 @@ export function GET(context: any) {
|
||||||
<link>https://www.zen-browser.app</link>
|
<link>https://www.zen-browser.app</link>
|
||||||
</image>
|
</image>
|
||||||
`,
|
`,
|
||||||
};
|
}
|
||||||
|
|
||||||
for (const releaseNote of releaseNotes.slice(0, RSS_ENTRY_LIMIT)) {
|
for (const releaseNote of releaseNotes.slice(0, RSS_ENTRY_LIMIT)) {
|
||||||
rssData.items.push({
|
rssData.items.push({
|
||||||
|
@ -42,10 +42,10 @@ export function GET(context: any) {
|
||||||
pubDate: formatRssDate(releaseNote.date as string),
|
pubDate: formatRssDate(releaseNote.date as string),
|
||||||
description: releaseNote.extra,
|
description: releaseNote.extra,
|
||||||
content: formatReleaseNote(releaseNote),
|
content: formatReleaseNote(releaseNote),
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return rss(rssData);
|
return rss(rssData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,15 +56,15 @@ export function GET(context: any) {
|
||||||
* @returns The passed in date string as a Date object.
|
* @returns The passed in date string as a Date object.
|
||||||
*/
|
*/
|
||||||
function formatRssDate(dateStr: string) {
|
function formatRssDate(dateStr: string) {
|
||||||
const splitDate = dateStr.split("/");
|
const splitDate = dateStr.split('/')
|
||||||
if (splitDate.length !== 3) {
|
if (splitDate.length !== 3) {
|
||||||
throw new Error("Invalid date format");
|
throw new Error('Invalid date format')
|
||||||
}
|
}
|
||||||
|
|
||||||
const day = Number(splitDate[0]);
|
const day = Number(splitDate[0])
|
||||||
const month = Number(splitDate[1]) - 1;
|
const month = Number(splitDate[1]) - 1
|
||||||
const year = Number(splitDate[2]);
|
const year = Number(splitDate[2])
|
||||||
return new Date(year, month, day);
|
return new Date(year, month, day)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,72 +76,72 @@ function formatReleaseNote(releaseNote: ReleaseNote) {
|
||||||
let content = `<p>
|
let content = `<p>
|
||||||
If you encounter any issues, please report them on <a href="https://github.com/zen-browser/desktop/issues/">the issues page</a>.
|
If you encounter any issues, please report them on <a href="https://github.com/zen-browser/desktop/issues/">the issues page</a>.
|
||||||
Thanks everyone for your feedback! ❤️
|
Thanks everyone for your feedback! ❤️
|
||||||
</p>`;
|
</p>`
|
||||||
|
|
||||||
if (releaseNote.image) {
|
if (releaseNote.image) {
|
||||||
content += `<img src="https://cdn.jsdelivr.net/gh/zen-browser/www/public/releases/${releaseNote.version}.png"
|
content += `<img src="https://cdn.jsdelivr.net/gh/zen-browser/www/public/releases/${releaseNote.version}.png"
|
||||||
alt="Release Image for version ${releaseNote.version}"
|
alt="Release Image for version ${releaseNote.version}"
|
||||||
style="max-width: 30em; width: 100%; border-radius: 0.5rem;"
|
style="max-width: 30em; width: 100%; border-radius: 0.5rem;"
|
||||||
/>`;
|
/>`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (releaseNote.extra) {
|
if (releaseNote.extra) {
|
||||||
content += `<p>${releaseNote.extra.replace(/(\n)/g, "<br />")}</p>`;
|
content += `<p>${releaseNote.extra.replace(/(\n)/g, '<br />')}</p>`
|
||||||
}
|
}
|
||||||
|
|
||||||
content += addReleaseNoteSection(
|
content += addReleaseNoteSection(
|
||||||
"⚠️ Breaking changes",
|
'⚠️ Breaking changes',
|
||||||
releaseNote.breakingChanges?.map(breakingChangeToReleaseNote),
|
releaseNote.breakingChanges?.map(breakingChangeToReleaseNote),
|
||||||
);
|
)
|
||||||
content += addReleaseNoteSection(
|
content += addReleaseNoteSection(
|
||||||
"✓ Fixes",
|
'✓ Fixes',
|
||||||
releaseNote.fixes?.map(fixToReleaseNote),
|
releaseNote.fixes?.map(fixToReleaseNote),
|
||||||
);
|
)
|
||||||
content += addReleaseNoteSection("🖌 Theme Changes", releaseNote.themeChanges);
|
content += addReleaseNoteSection('🖌 Theme Changes', releaseNote.themeChanges)
|
||||||
content += addReleaseNoteSection("⭐ Features", releaseNote.features);
|
content += addReleaseNoteSection('⭐ Features', releaseNote.features)
|
||||||
|
|
||||||
return content;
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
function addReleaseNoteSection(title: string, items?: string[]): string {
|
function addReleaseNoteSection(title: string, items?: string[]): string {
|
||||||
if (!items) {
|
if (!items) {
|
||||||
return "";
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = `<h2>${title}</h2>`;
|
let content = `<h2>${title}</h2>`
|
||||||
content += `<ul>`;
|
content += `<ul>`
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
if (item && item.length > 0) {
|
if (item && item.length > 0) {
|
||||||
content += `<li>${item}</li>`;
|
content += `<li>${item}</li>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
content += `</ul>`;
|
content += `</ul>`
|
||||||
return content;
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixToReleaseNote(
|
function fixToReleaseNote(
|
||||||
fix?: Exclude<ReleaseNote["fixes"], undefined>[number],
|
fix?: Exclude<ReleaseNote['fixes'], undefined>[number],
|
||||||
) {
|
) {
|
||||||
if (typeof fix === "string") {
|
if (typeof fix === 'string') {
|
||||||
return fix;
|
return fix
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fix || !fix.description || fix.description.length === 0) {
|
if (!fix || !fix.description || fix.description.length === 0) {
|
||||||
return "";
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
let note = fix.description;
|
let note = fix.description
|
||||||
if (fix.issue) {
|
if (fix.issue) {
|
||||||
note += ` (<a href="https://github.com/zen-browser/desktop/issues/${fix.issue}" target="_blank">#${fix.issue}</a>)`;
|
note += ` (<a href="https://github.com/zen-browser/desktop/issues/${fix.issue}" target="_blank">#${fix.issue}</a>)`
|
||||||
}
|
}
|
||||||
return note;
|
return note
|
||||||
}
|
}
|
||||||
|
|
||||||
function breakingChangeToReleaseNote(
|
function breakingChangeToReleaseNote(
|
||||||
breakingChange?: Exclude<ReleaseNote["breakingChanges"], undefined>[number],
|
breakingChange?: Exclude<ReleaseNote['breakingChanges'], undefined>[number],
|
||||||
) {
|
) {
|
||||||
if (typeof breakingChange === "string") {
|
if (typeof breakingChange === 'string') {
|
||||||
return breakingChange;
|
return breakingChange
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -149,26 +149,26 @@ function breakingChangeToReleaseNote(
|
||||||
!breakingChange.description ||
|
!breakingChange.description ||
|
||||||
breakingChange.description.length === 0
|
breakingChange.description.length === 0
|
||||||
) {
|
) {
|
||||||
return "";
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${breakingChange.description} (<a href="${breakingChange.link}" target="_blank">Learn more</a>)`;
|
return `${breakingChange.description} (<a href="${breakingChange.link}" target="_blank">Learn more</a>)`
|
||||||
}
|
}
|
||||||
|
|
||||||
function pubDate(date?: Date) {
|
function pubDate(date?: Date) {
|
||||||
date ??= new Date();
|
date ??= new Date()
|
||||||
|
|
||||||
const pieces = date.toString().split(" ");
|
const pieces = date.toString().split(' ')
|
||||||
const offsetTime = pieces[5].match(/[-+]\d{4}/);
|
const offsetTime = pieces[5].match(/[-+]\d{4}/)
|
||||||
const offset = offsetTime ? offsetTime : pieces[5];
|
const offset = offsetTime ? offsetTime : pieces[5]
|
||||||
const parts = [
|
const parts = [
|
||||||
pieces[0] + ",",
|
pieces[0] + ',',
|
||||||
pieces[2],
|
pieces[2],
|
||||||
pieces[1],
|
pieces[1],
|
||||||
pieces[3],
|
pieces[3],
|
||||||
pieces[4],
|
pieces[4],
|
||||||
offset,
|
offset,
|
||||||
];
|
]
|
||||||
|
|
||||||
return parts.join(" ");
|
return parts.join(' ')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
---
|
---
|
||||||
import Community from "~/components/Community.astro";
|
import Community from '~/components/Community.astro'
|
||||||
import Features from "~/components/Features.astro";
|
import Features from '~/components/Features.astro'
|
||||||
import Hero from "~/components/Hero.astro";
|
import Hero from '~/components/Hero.astro'
|
||||||
import Sponsors from "~/components/Sponsors.astro";
|
import Sponsors from '~/components/Sponsors.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const { layout } = getUI(locale);
|
const { layout } = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout
|
<Layout
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
---
|
---
|
||||||
import { ArrowRight, Info } from "lucide-astro";
|
import { ArrowRight, Info } from 'lucide-astro'
|
||||||
import BackButton from "~/components/BackButton.astro";
|
import BackButton from '~/components/BackButton.astro'
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getAllMods, getAuthorLink, getLocalizedDate } from "~/mods";
|
import { getAllMods, getAuthorLink, getLocalizedDate } from '~/mods'
|
||||||
import { getUI } from "~/utils/i18n";
|
import { getUI } from '~/utils/i18n'
|
||||||
import { getLocale, getOtherLocales } from "~/utils/i18n";
|
import { getLocale, getOtherLocales } from '~/utils/i18n'
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const mods = await getAllMods();
|
const mods = await getAllMods()
|
||||||
return mods.flatMap((mod) => [
|
return mods.flatMap((mod) => [
|
||||||
...getOtherLocales().map((locale) => ({
|
...getOtherLocales().map((locale) => ({
|
||||||
params: {
|
params: {
|
||||||
|
@ -31,25 +31,25 @@ export async function getStaticPaths() {
|
||||||
locale: undefined,
|
locale: undefined,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/TeaClientMC/Website/blob/7faacc9f8b2c79c74f711d413b155c84faafc00d/src/pages/news/%5B...slug%5D.astro
|
// https://github.com/TeaClientMC/Website/blob/7faacc9f8b2c79c74f711d413b155c84faafc00d/src/pages/news/%5B...slug%5D.astro
|
||||||
|
|
||||||
const mod = Astro.props;
|
const mod = Astro.props
|
||||||
|
|
||||||
const dates = {
|
const dates = {
|
||||||
createdAt: getLocalizedDate(mod.createdAt),
|
createdAt: getLocalizedDate(mod.createdAt),
|
||||||
updatedAt: getLocalizedDate(mod.updatedAt),
|
updatedAt: getLocalizedDate(mod.updatedAt),
|
||||||
};
|
}
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: {
|
routes: {
|
||||||
mods: { slug },
|
mods: { slug },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout
|
<Layout
|
||||||
|
@ -104,7 +104,7 @@ const {
|
||||||
<p
|
<p
|
||||||
set:html={slug.latestUpdate.replace(
|
set:html={slug.latestUpdate.replace(
|
||||||
'{updatedAt}',
|
'{updatedAt}',
|
||||||
dates.updatedAt
|
dates.updatedAt,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
---
|
---
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import ModsList from "~/components/ModsList";
|
import ModsList from '~/components/ModsList'
|
||||||
import { CONSTANT } from "~/constants";
|
import { CONSTANT } from '~/constants'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getAllMods } from "~/mods";
|
import { getAllMods } from '~/mods'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: { mods },
|
routes: { mods },
|
||||||
layout,
|
layout,
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
|
|
||||||
const allMods = (await getAllMods()) || [];
|
const allMods = (await getAllMods()) || []
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={layout.mods.title}>
|
<Layout title={layout.mods.title}>
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
---
|
---
|
||||||
import Title from "~/components/Title.astro";
|
import Title from '~/components/Title.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: { privacyPolicy },
|
routes: { privacyPolicy },
|
||||||
layout,
|
layout,
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout
|
<Layout
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
---
|
---
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { releaseNotes } from "~/release-notes";
|
import { releaseNotes } from '~/release-notes'
|
||||||
import { getStaticPaths as getI18nPaths, getLocale, getUI } from "~/utils/i18n";
|
import { getStaticPaths as getI18nPaths, getLocale, getUI } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: {
|
routes: {
|
||||||
releaseNotes: { slug },
|
releaseNotes: { slug },
|
||||||
},
|
},
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const i18nPaths = getI18nPaths();
|
const i18nPaths = getI18nPaths()
|
||||||
|
|
||||||
return i18nPaths.flatMap(({ params: { locale } }) => [
|
return i18nPaths.flatMap(({ params: { locale } }) => [
|
||||||
...releaseNotes.map((release: any) => ({
|
...releaseNotes.map((release: any) => ({
|
||||||
|
@ -20,13 +20,13 @@ export async function getStaticPaths() {
|
||||||
props: { ...release },
|
props: { ...release },
|
||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
params: { slug: "latest", locale },
|
params: { slug: 'latest', locale },
|
||||||
props: { ...releaseNotes[0] },
|
props: { ...releaseNotes[0] },
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
const release = Astro.props;
|
const release = Astro.props
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={slug.title} redirect={`/release-notes#${release.version}`}>
|
<Layout title={slug.title} redirect={`/release-notes#${release.version}`}>
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
---
|
---
|
||||||
import { Modal, ModalBody, ModalHeader } from "free-astro-components";
|
import { Modal, ModalBody, ModalHeader } from 'free-astro-components'
|
||||||
import { ArrowUp } from "lucide-astro";
|
import { ArrowUp } from 'lucide-astro'
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import ReleaseNoteItem from "~/components/ReleaseNoteItem.astro";
|
import ReleaseNoteItem from '~/components/ReleaseNoteItem.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import {
|
import {
|
||||||
releaseNotes as releaseNotesData,
|
releaseNotes as releaseNotesData,
|
||||||
releaseNotesTwilight,
|
releaseNotesTwilight,
|
||||||
} from "~/release-notes";
|
} from '~/release-notes'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: { releaseNotes },
|
routes: { releaseNotes },
|
||||||
layout,
|
layout,
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={layout.releaseNotes.title}>
|
<Layout title={layout.releaseNotes.title}>
|
||||||
|
@ -33,7 +33,7 @@ const {
|
||||||
class="text-base opacity-55"
|
class="text-base opacity-55"
|
||||||
set:html={releaseNotes.topSection.description.replaceAll(
|
set:html={releaseNotes.topSection.description.replaceAll(
|
||||||
'{latestVersion}',
|
'{latestVersion}',
|
||||||
releaseNotesData[0].version
|
releaseNotesData[0].version,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
---
|
---
|
||||||
import Features from "~/components/Features.astro";
|
import Features from '~/components/Features.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: { welcome },
|
routes: { welcome },
|
||||||
layout,
|
layout,
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={layout.welcome.title} description={layout.welcome.description}>
|
<Layout title={layout.welcome.title} description={layout.welcome.description}>
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
---
|
---
|
||||||
import { ArrowRight } from "lucide-astro";
|
import { ArrowRight } from 'lucide-astro'
|
||||||
import Button from "~/components/Button.astro";
|
import Button from '~/components/Button.astro'
|
||||||
import Description from "~/components/Description.astro";
|
import Description from '~/components/Description.astro'
|
||||||
import SocialMediaStrip from "~/components/SocialMediaStrip.astro";
|
import SocialMediaStrip from '~/components/SocialMediaStrip.astro'
|
||||||
import Layout from "~/layouts/Layout.astro";
|
import Layout from '~/layouts/Layout.astro'
|
||||||
|
|
||||||
import whatsNewVideo from "~/assets/whats-new.mp4";
|
import whatsNewVideo from '~/assets/whats-new.mp4'
|
||||||
import Video from "~/components/Video.astro";
|
import Video from '~/components/Video.astro'
|
||||||
import { releaseNotes } from "~/release-notes";
|
import { releaseNotes } from '~/release-notes'
|
||||||
import whatsNewText from "~/release-notes/whats-new.json";
|
import whatsNewText from '~/release-notes/whats-new.json'
|
||||||
import { getLocale, getUI } from "~/utils/i18n";
|
import { getLocale, getUI } from '~/utils/i18n'
|
||||||
export { getStaticPaths } from "~/utils/i18n";
|
export { getStaticPaths } from '~/utils/i18n'
|
||||||
|
|
||||||
const latestVersion = releaseNotes[0];
|
const latestVersion = releaseNotes[0]
|
||||||
|
|
||||||
const locale = getLocale(Astro);
|
const locale = getLocale(Astro)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
routes: { whatsNew },
|
routes: { whatsNew },
|
||||||
layout,
|
layout,
|
||||||
} = getUI(locale);
|
} = getUI(locale)
|
||||||
|
|
||||||
// Just redirect to the release notes if we are in a patch version
|
// Just redirect to the release notes if we are in a patch version
|
||||||
if (
|
if (
|
||||||
latestVersion.version.split(".").length > 2 &&
|
latestVersion.version.split('.').length > 2 &&
|
||||||
whatsNewText[1] !== latestVersion.version
|
whatsNewText[1] !== latestVersion.version
|
||||||
) {
|
) {
|
||||||
return Astro.redirect(`/release-notes#${latestVersion.version}`);
|
return Astro.redirect(`/release-notes#${latestVersion.version}`)
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout
|
<Layout
|
||||||
title={layout.whatsNew.title.replace(
|
title={layout.whatsNew.title.replace(
|
||||||
'{latestVersion.version}',
|
'{latestVersion.version}',
|
||||||
latestVersion.version
|
latestVersion.version,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<main
|
<main
|
||||||
|
@ -45,7 +45,7 @@ if (
|
||||||
>{
|
>{
|
||||||
whatsNew.title.replace(
|
whatsNew.title.replace(
|
||||||
'{latestVersion.version}',
|
'{latestVersion.version}',
|
||||||
latestVersion.version
|
latestVersion.version,
|
||||||
)
|
)
|
||||||
}</Description
|
}</Description
|
||||||
>
|
>
|
||||||
|
|
|
@ -3,25 +3,29 @@
|
||||||
* Returns a mapping from filename to checksum.
|
* Returns a mapping from filename to checksum.
|
||||||
*/
|
*/
|
||||||
export async function getChecksums() {
|
export async function getChecksums() {
|
||||||
const res = await fetch('https://api.github.com/repos/zen-browser/desktop/releases/latest', {
|
const res = await fetch(
|
||||||
|
'https://api.github.com/repos/zen-browser/desktop/releases/latest',
|
||||||
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/vnd.github+json',
|
Accept: 'application/vnd.github+json',
|
||||||
'X-GitHub-Api-Version': '2022-11-28',
|
'X-GitHub-Api-Version': '2022-11-28',
|
||||||
'User-Agent': 'zen-browser-checksum-fetcher',
|
'User-Agent': 'zen-browser-checksum-fetcher',
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
if (!res.ok) throw new Error('Failed to fetch GitHub release: ' + res.statusText);
|
)
|
||||||
const data = await res.json();
|
if (!res.ok)
|
||||||
const body = data.body as string;
|
throw new Error('Failed to fetch GitHub release: ' + res.statusText)
|
||||||
|
const data = await res.json()
|
||||||
|
const body = data.body as string
|
||||||
|
|
||||||
// Extract the checksum block
|
// Extract the checksum block
|
||||||
const match = body.match(/File Checksums \(SHA-256\)[\s\S]*?```([\s\S]*?)```/);
|
const match = body.match(/File Checksums \(SHA-256\)[\s\S]*?```([\s\S]*?)```/)
|
||||||
const checksums: Record<string, string> = {};
|
const checksums: Record<string, string> = {}
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
match[1].split('\n').forEach(line => {
|
match[1].split('\n').forEach((line) => {
|
||||||
const [hash, filename] = line.trim().split(/\s+/, 2);
|
const [hash, filename] = line.trim().split(/\s+/, 2)
|
||||||
if (hash && filename) checksums[filename] = hash;
|
if (hash && filename) checksums[filename] = hash
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return checksums;
|
return checksums
|
||||||
}
|
}
|
|
@ -1,67 +1,67 @@
|
||||||
import type { GetStaticPaths } from "astro";
|
import type { GetStaticPaths } from 'astro'
|
||||||
import { CONSTANT } from "~/constants";
|
import { CONSTANT } from '~/constants'
|
||||||
import UI_EN from "~/i18n/en/translation.json";
|
import UI_EN from '~/i18n/en/translation.json'
|
||||||
|
|
||||||
export type Locale = (typeof locales)[number];
|
export type Locale = (typeof locales)[number]
|
||||||
|
|
||||||
export const getPath = (locale?: Locale) => (path: string) => {
|
export const getPath = (locale?: Locale) => (path: string) => {
|
||||||
if (locale && !path.startsWith(`/${locale}`)) {
|
if (locale && !path.startsWith(`/${locale}`)) {
|
||||||
return `/${locale}${path.startsWith("/") ? "" : "/"}${path}`;
|
return `/${locale}${path.startsWith('/') ? '' : '/'}${path}`
|
||||||
|
}
|
||||||
|
return path
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getLocale = (Astro: any) => {
|
export const getLocale = (Astro: any) => {
|
||||||
if (Astro.params.locale) {
|
if (Astro.params.locale) {
|
||||||
return Astro.params.locale as Locale;
|
return Astro.params.locale as Locale
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
export const locales = CONSTANT.I18N.LOCALES.map(({ value }) => value);
|
export const locales = CONSTANT.I18N.LOCALES.map(({ value }) => value)
|
||||||
|
|
||||||
const otherLocales = CONSTANT.I18N.LOCALES.filter(
|
const otherLocales = CONSTANT.I18N.LOCALES.filter(
|
||||||
({ value }) => value !== CONSTANT.I18N.DEFAULT_LOCALE,
|
({ value }) => value !== CONSTANT.I18N.DEFAULT_LOCALE,
|
||||||
);
|
)
|
||||||
|
|
||||||
export const getOtherLocales = () => otherLocales;
|
export const getOtherLocales = () => otherLocales
|
||||||
|
|
||||||
export type UI = typeof UI_EN;
|
export type UI = typeof UI_EN
|
||||||
|
|
||||||
export const ui = { en: UI_EN };
|
export const ui = { en: UI_EN }
|
||||||
|
|
||||||
export const getUI = (locale?: Locale | string): UI => {
|
export const getUI = (locale?: Locale | string): UI => {
|
||||||
const validLocale = locales.includes(locale as Locale)
|
const validLocale = locales.includes(locale as Locale)
|
||||||
? locale
|
? locale
|
||||||
: CONSTANT.I18N.DEFAULT_LOCALE;
|
: CONSTANT.I18N.DEFAULT_LOCALE
|
||||||
const defaultUI = ui[CONSTANT.I18N.DEFAULT_LOCALE];
|
const defaultUI = ui[CONSTANT.I18N.DEFAULT_LOCALE]
|
||||||
const localeUI = ui[validLocale as Locale];
|
const localeUI = ui[validLocale as Locale]
|
||||||
|
|
||||||
function deepMerge<T>(defaultObj: T, overrideObj: Partial<T>): T {
|
function deepMerge<T>(defaultObj: T, overrideObj: Partial<T>): T {
|
||||||
if (typeof defaultObj !== "object" || defaultObj === null)
|
if (typeof defaultObj !== 'object' || defaultObj === null)
|
||||||
return (overrideObj ?? defaultObj) as T;
|
return (overrideObj ?? defaultObj) as T
|
||||||
if (typeof overrideObj !== "object" || overrideObj === null)
|
if (typeof overrideObj !== 'object' || overrideObj === null)
|
||||||
return (overrideObj ?? defaultObj) as T;
|
return (overrideObj ?? defaultObj) as T
|
||||||
const result: any = Array.isArray(defaultObj)
|
const result: any = Array.isArray(defaultObj)
|
||||||
? [...defaultObj]
|
? [...defaultObj]
|
||||||
: { ...defaultObj };
|
: { ...defaultObj }
|
||||||
for (const key in defaultObj) {
|
for (const key in defaultObj) {
|
||||||
if (Object.prototype.hasOwnProperty.call(defaultObj, key)) {
|
if (Object.prototype.hasOwnProperty.call(defaultObj, key)) {
|
||||||
result[key] = deepMerge(
|
result[key] = deepMerge(
|
||||||
(defaultObj as any)[key],
|
(defaultObj as any)[key],
|
||||||
(overrideObj as any)?.[key],
|
(overrideObj as any)?.[key],
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const key in overrideObj) {
|
for (const key in overrideObj) {
|
||||||
if (!(key in defaultObj)) {
|
if (!(key in defaultObj)) {
|
||||||
result[key] = (overrideObj as any)[key];
|
result[key] = (overrideObj as any)[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result as T;
|
return result as T
|
||||||
}
|
}
|
||||||
|
|
||||||
return deepMerge<UI>(defaultUI, localeUI);
|
return deepMerge<UI>(defaultUI, localeUI)
|
||||||
};
|
}
|
||||||
|
|
||||||
export const getStaticPaths = (() => {
|
export const getStaticPaths = (() => {
|
||||||
return [
|
return [
|
||||||
|
@ -77,9 +77,9 @@ export const getStaticPaths = (() => {
|
||||||
locale: value,
|
locale: value,
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
];
|
]
|
||||||
}) satisfies GetStaticPaths;
|
}) satisfies GetStaticPaths
|
||||||
|
|
||||||
export const getLocales = () => {
|
export const getLocales = () => {
|
||||||
return [...locales, ...otherLocales];
|
return [...locales, ...otherLocales]
|
||||||
};
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue