mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 14:00:39 -07:00
docs: remove translations & update homepage (#904)
* docs: add GitHub buttons and improve option docs
* chore: replace husky with prepush check
* docs: revamp homepage and switch to custom GitHub buttons
- Make the docs English-only by removing all zh-cn content, the language switcher UI, and related JS/config
- Rework homepage feature cards (Safe & Typed, Pure JavaScript, Shopify & Jekyll, Streaming) and refresh section colors/layout
- Replace buttons.github.io with custom Star/Sponsor buttons featuring a live star count and dark-mode support
- Drop the buttons.js script and tidy banner, header, footer, and share partials
Co-authored-by: Cursor <[email protected]>
* fix: restore tsconfig settings and changelog build
Re-add suppressImplicitAnyIndexErrors and downlevelIteration removed in
a75033e2c, which broke the rollup TypeScript build on CI. Drop zh-cn
changelog output now that translations were removed.
Co-authored-by: Cursor <[email protected]>
* fix: resolve TS errors without deprecated tsconfig options
Co-authored-by: Cursor <[email protected]>
---------
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
+4
-4
@@ -18,10 +18,10 @@ export async function toPromise<T> (val: Generator<unknown, T, unknown> | Promis
|
||||
if (!isIterator(val)) return val
|
||||
let value: unknown
|
||||
let done = false
|
||||
let next = 'next'
|
||||
let next: 'next' | 'throw' = 'next'
|
||||
do {
|
||||
const state = val[next](value)
|
||||
done = state.done
|
||||
done = !!state.done
|
||||
value = state.value
|
||||
next = 'next'
|
||||
try {
|
||||
@@ -40,10 +40,10 @@ export function toValueSync<T> (val: Generator<unknown, T, unknown> | T): T {
|
||||
if (!isIterator(val)) return val
|
||||
let value: any
|
||||
let done = false
|
||||
let next = 'next'
|
||||
let next: 'next' | 'throw' = 'next'
|
||||
do {
|
||||
const state = val[next](value)
|
||||
done = state.done
|
||||
done = !!state.done
|
||||
value = state.value
|
||||
next = 'next'
|
||||
if (isIterator(value)) {
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ export abstract class LiquidError extends Error {
|
||||
if (this.originalError) this.stack += '\nFrom ' + this.originalError.stack
|
||||
}
|
||||
static is (obj: unknown): obj is LiquidError {
|
||||
return obj?.[TRAIT] === 'LiquidError'
|
||||
return (obj as Record<string, unknown> | null | undefined)?.[TRAIT] === 'LiquidError'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,22 +4,16 @@ interface TrieInput<T> {
|
||||
[key: string]: T
|
||||
}
|
||||
|
||||
interface TrieLeafNode<T> {
|
||||
data: T;
|
||||
end: true;
|
||||
needBoundary?: true;
|
||||
}
|
||||
|
||||
export interface Trie<T> {
|
||||
[key: string]: Trie<T> | TrieLeafNode<T>;
|
||||
}
|
||||
|
||||
export type TrieNode<T> = Trie<T> | TrieLeafNode<T>
|
||||
export type Trie<T> = {
|
||||
data?: T
|
||||
end?: true
|
||||
needBoundary?: true
|
||||
} & Record<string, any>
|
||||
|
||||
export function createTrie<T = any> (input: TrieInput<T>): Trie<T> {
|
||||
const trie: Trie<T> = {}
|
||||
for (const [name, data] of Object.entries(input)) {
|
||||
let node: Trie<T> | TrieLeafNode<T> = trie
|
||||
let node = trie
|
||||
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
const c = name[i]
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { Limiter } from './limiter'
|
||||
|
||||
const rFormat = /%([-_0^#:]+)?(\d+)?([EO])?(.)/
|
||||
interface FormatOptions {
|
||||
flags: object;
|
||||
flags: Record<string, boolean>;
|
||||
width?: string;
|
||||
modifier?: string;
|
||||
memoryLimit?: Pick<Limiter, 'use'>;
|
||||
@@ -50,7 +50,7 @@ function century (d: LiquidDate) {
|
||||
}
|
||||
|
||||
// default to 0
|
||||
const padWidths = {
|
||||
const padWidths: Record<string, number> = {
|
||||
d: 2,
|
||||
e: 2,
|
||||
H: 2,
|
||||
@@ -77,7 +77,9 @@ function getTimezoneOffset (d: LiquidDate, opts: FormatOptions) {
|
||||
(opts.flags[':'] ? ':' : '') +
|
||||
padStart(m, 2, '0')
|
||||
}
|
||||
const formatCodes = {
|
||||
type FormatCodeHandler = (d: LiquidDate, opts: FormatOptions) => unknown
|
||||
|
||||
const formatCodes: Record<string, FormatCodeHandler> = {
|
||||
a: (d: LiquidDate) => d.getShortWeekdayName(),
|
||||
A: (d: LiquidDate) => d.getLongWeekdayName(),
|
||||
b: (d: LiquidDate) => d.getShortMonthName(),
|
||||
@@ -118,8 +120,8 @@ const formatCodes = {
|
||||
't': () => '\t',
|
||||
'n': () => '\n',
|
||||
'%': () => '%'
|
||||
};
|
||||
(formatCodes as any).h = formatCodes.b
|
||||
}
|
||||
formatCodes.h = formatCodes.b
|
||||
|
||||
export function strftime (d: LiquidDate, formatStr: string, memoryLimit?: Pick<Limiter, 'use'>) {
|
||||
let output = ''
|
||||
@@ -137,11 +139,11 @@ function format (d: LiquidDate, match: RegExpExecArray, memoryLimit?: Pick<Limit
|
||||
const [input, flagStr = '', width, modifier, conversion] = match
|
||||
const convert = formatCodes[conversion]
|
||||
if (!convert) return input
|
||||
const flags = {}
|
||||
const flags: Record<string, boolean> = {}
|
||||
for (const flag of flagStr) flags[flag] = true
|
||||
let ret = String(convert(d, { flags, width, modifier, memoryLimit }))
|
||||
let padChar = padSpaceChars.has(conversion) ? ' ' : '0'
|
||||
let padWidth = width || padWidths[conversion] || 0
|
||||
let padWidth = Number(width) || padWidths[conversion] || 0
|
||||
if (flags['^']) ret = ret.toUpperCase()
|
||||
else if (flags['#']) ret = changeCase(ret)
|
||||
if (flags['_']) padChar = ' '
|
||||
|
||||
Reference in New Issue
Block a user