このコミットが含まれているのは:
@@ -31,6 +31,42 @@ export type HelpDiff = {
|
||||
to: HelpEditionSource
|
||||
lines: HelpDiffLine[] }
|
||||
|
||||
export type HelpEditionIdentifier = { date: string; revision: number | null }
|
||||
|
||||
|
||||
export const normaliseHelpSearchText = (value: string): string =>
|
||||
value.normalize ('NFKC').toLowerCase ().replace (/[ァ-ヶヽヾ]/g,
|
||||
character => String.fromCodePoint (character.codePointAt (0)! - 0x60))
|
||||
|
||||
|
||||
export const parseHelpEdition = (edition: string): HelpEditionIdentifier | null => {
|
||||
const matched = edition.match (/^(\d{4}-\d{2}-\d{2})(?:\.([1-9]\d*))?$/)
|
||||
if (matched == null)
|
||||
return null
|
||||
const date = new Date (matched[1])
|
||||
const revision = matched[2] == null ? null : Number (matched[2])
|
||||
if (Number.isNaN (date.getTime ()) || date.toISOString ().slice (0, 10) !== matched[1]
|
||||
|| (revision != null && !(Number.isSafeInteger (revision))))
|
||||
return null
|
||||
return { date: matched[1], revision }
|
||||
}
|
||||
|
||||
|
||||
export const compareHelpEditions = (a: string, b: string): number => {
|
||||
const before = parseHelpEdition (a)
|
||||
const after = parseHelpEdition (b)
|
||||
if (before == null || after == null)
|
||||
return a.localeCompare (b)
|
||||
return before.date.localeCompare (after.date)
|
||||
|| (before.revision ?? 1) - (after.revision ?? 1)
|
||||
}
|
||||
|
||||
|
||||
export const helpEditionDate = (edition: string): Date | null => {
|
||||
const parsed = parseHelpEdition (edition)
|
||||
return parsed == null ? null : new Date (`${ parsed.date }T00:00:00`)
|
||||
}
|
||||
|
||||
|
||||
export const getHelpArticle = async (identifier: string): Promise<ArticleMeta | null> => {
|
||||
const { default: articles } = await import ('virtual:help/articles')
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする