You've already forked AstralRinth
forked from didirus/AstralRinth
Fix server-side rendering
This commit is contained in:
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>
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ export function ago(
|
|||||||
{ ge: 30 * SECOND, divisor: SECOND, unit: 'seconds' },
|
{ ge: 30 * SECOND, divisor: SECOND, unit: 'seconds' },
|
||||||
{ ge: 0, divisor: 1, text: 'just now' },
|
{ 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 now = typeof nowDate === 'object' ? nowDate.getTime() : new Date(nowDate).getTime()
|
||||||
const diff = now - (typeof date === 'object' ? date : new Date(date)).getTime()
|
const diff = now - (typeof date === 'object' ? date : new Date(date)).getTime()
|
||||||
const diffAbs = Math.abs(diff)
|
const diffAbs = Math.abs(diff)
|
||||||
@@ -37,7 +35,10 @@ 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 (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 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
|
||||||
@@ -110,4 +111,4 @@ function chs_format(value: number, isFuture: boolean, unit: Unit): string {
|
|||||||
quantifier = '个'
|
quantifier = '个'
|
||||||
}
|
}
|
||||||
return `${value} ${quantifier}${chsUnit}${isFuture ? '后' : '前'}`
|
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