You've already forked AstralRinth
forked from didirus/AstralRinth
3852
pnpm-lock.yaml
generated
3852
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="description" content="" />
|
<meta name="description" content="" />
|
||||||
<link rel="icon" href="%svelte.assets%/assets/omorphia.png" />
|
<link rel="icon" href="%sveltekit.assets%/assets/omorphia.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
|
||||||
<meta name="theme-color" content="#CF1971" />
|
<meta name="theme-color" content="#CF1971" />
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
<meta name="twitter:image" content="https://omorphia.modrinth.com/assets/omorphia.png" />
|
<meta name="twitter:image" content="https://omorphia.modrinth.com/assets/omorphia.png" />
|
||||||
<meta property="og:site_name" content="Modrinth" />
|
<meta property="og:site_name" content="Modrinth" />
|
||||||
|
|
||||||
%svelte.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
%svelte.body%
|
%sveltekit.body%
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ export function ago(
|
|||||||
if (diffAbs >= interval.ge) {
|
if (diffAbs >= interval.ge) {
|
||||||
const x = Math.round(Math.abs(diff) / interval.divisor)
|
const x = Math.round(Math.abs(diff) / interval.divisor)
|
||||||
const isFuture = diff < 0
|
const isFuture = diff < 0
|
||||||
|
if (
|
||||||
|
typeof navigator !== 'undefined' &&
|
||||||
|
(navigator.language === 'zh-CN' || navigator.language === 'zh')
|
||||||
|
) {
|
||||||
|
return chs_format(x, isFuture, interval.unit as Unit)
|
||||||
|
}
|
||||||
return interval.unit ? rft.format(isFuture ? x : -x, interval.unit as Unit) : interval.text
|
return interval.unit ? rft.format(isFuture ? x : -x, interval.unit as Unit) : interval.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,3 +61,54 @@ type Unit =
|
|||||||
| 'months'
|
| 'months'
|
||||||
| 'year'
|
| 'year'
|
||||||
| 'years'
|
| 'years'
|
||||||
|
|
||||||
|
type ChsUnit = '秒' | '分' | '小时' | '天' | '周' | '月' | '年'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert unit to chinese unit
|
||||||
|
* @param unit
|
||||||
|
* @returns {ChsUnit}
|
||||||
|
*/
|
||||||
|
function convertUnitToChsUnit(unit: Unit): ChsUnit {
|
||||||
|
switch (unit) {
|
||||||
|
case 'second':
|
||||||
|
case 'seconds':
|
||||||
|
return '秒'
|
||||||
|
case 'minute':
|
||||||
|
case 'minutes':
|
||||||
|
return '分'
|
||||||
|
case 'hour':
|
||||||
|
case 'hours':
|
||||||
|
return '小时'
|
||||||
|
case 'day':
|
||||||
|
case 'days':
|
||||||
|
return '天'
|
||||||
|
case 'week':
|
||||||
|
case 'weeks':
|
||||||
|
return '周'
|
||||||
|
case 'month':
|
||||||
|
case 'months':
|
||||||
|
return '月'
|
||||||
|
case 'year':
|
||||||
|
case 'years':
|
||||||
|
return '年'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default converter provided by js does not conform to Chinese typography.
|
||||||
|
* @param value date value
|
||||||
|
* @param isFuture
|
||||||
|
* @param unit
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function chs_format(value: number, isFuture: boolean, unit: Unit): string {
|
||||||
|
const chsUnit = convertUnitToChsUnit(unit)
|
||||||
|
let quantifier = ''
|
||||||
|
switch (chsUnit) {
|
||||||
|
case '月':
|
||||||
|
case '小时':
|
||||||
|
quantifier = '个'
|
||||||
|
}
|
||||||
|
return `${value} ${quantifier}${chsUnit}${isFuture ? '后' : '前'}`
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ The `markdown` parser is designed for bodies of markdown text and supports image
|
|||||||
|
|
||||||
```svelte example
|
```svelte example
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { markdown } from "omorphia"
|
import { markdown } from "omorphia/utils"
|
||||||
|
|
||||||
const source = '## Example markdown \n\
|
const source = '## Example markdown \n\
|
||||||
This is **some** *text*! \n\
|
This is **some** *text*! \n\
|
||||||
|
|||||||
Reference in New Issue
Block a user