/
spirzen
/
it-knowledge-base
Обзор
Документация
Войти
/
spirzen
/
it-knowledge-base
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/components/RandomArticle/pickRandomDoc.js
19 строк
447 B
Spirzen
Added quick search and sidebar tools
25 май 2026, 13:48
25 май 2026, 13:48
bc213cb
Код
Авторство
О чём код?
/** @typedef {{ u: string, t: string, d?: string, s?: string }} DocEntry */ /** * @param {DocEntry[]} docs * @returns {DocEntry | null} */ export function pickRandomDoc(docs) { const pool = docs.filter( (doc) => doc.t && doc.t.length > 2 && !doc.u.endsWith('/intro') && !doc.u.includes('/_category_'), ); if (pool.length === 0) { return null; } return pool[Math.floor(Math.random() * pool.length)]; }