Fix server-side rendering
This commit is contained in:
parent
90b49106f0
commit
347366e8d7
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>
|
||||
<meta charset="utf-8" />
|
||||
<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="theme-color" content="#CF1971" />
|
||||
@ -11,9 +11,9 @@
|
||||
<meta name="twitter:image" content="https://omorphia.modrinth.com/assets/omorphia.png" />
|
||||
<meta property="og:site_name" content="Modrinth" />
|
||||
|
||||
%svelte.head%
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body>
|
||||
%svelte.body%
|
||||
%sveltekit.body%
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -28,8 +28,6 @@ export function ago(
|
||||
{ ge: 30 * SECOND, divisor: SECOND, unit: 'seconds' },
|
||||
{ ge: 0, divisor: 1, text: 'just now' },
|
||||
]
|
||||
// must get language from browser
|
||||
const firstLanguage = navigator.language
|
||||
const now = typeof nowDate === 'object' ? nowDate.getTime() : new Date(nowDate).getTime()
|
||||
const diff = now - (typeof date === 'object' ? date : new Date(date)).getTime()
|
||||
const diffAbs = Math.abs(diff)
|
||||
@ -37,7 +35,10 @@ export function ago(
|
||||
if (diffAbs >= interval.ge) {
|
||||
const x = Math.round(Math.abs(diff) / interval.divisor)
|
||||
const isFuture = diff < 0
|
||||
if (firstLanguage === 'zh-CN' || firstLanguage === 'zh') {
|
||||
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
|
||||
@ -110,4 +111,4 @@ function chs_format(value: number, isFuture: boolean, unit: Unit): string {
|
||||
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
|
||||
<script lang="ts">
|
||||
import { markdown } from "omorphia"
|
||||
import { markdown } from "omorphia/utils"
|
||||
|
||||
const source = '## Example markdown \n\
|
||||
This is **some** *text*! \n\
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user