/
githubmirror
/
docusaurus
Обзор
Документация
Войти
/
githubmirror
/
docusaurus
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/docusaurus-theme-common/src/utils/IntlUtils.ts
27 строк
726 B
ozaki
refactor(theme): dates should be formatted on the client-side instead of in nodejs code (#9868)
23 фев 2024, 20:30
Не верифицирован
23 фев 2024, 20:30
0279c32
Код
Авторство
О чём код?
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; export function useCalendar(): string { const { i18n: {currentLocale, localeConfigs}, } = useDocusaurusContext(); return localeConfigs[currentLocale]!.calendar; } export function useDateTimeFormat( options: Intl.DateTimeFormatOptions = {}, ): Intl.DateTimeFormat { const { i18n: {currentLocale}, } = useDocusaurusContext(); const calendar = useCalendar(); return new Intl.DateTimeFormat(currentLocale, { calendar, ...options, }); }