Files
tier-maker/frontend/src/lib/paths.js
2026-04-07 12:44:24 +09:00

60 lines
1.5 KiB
JavaScript

function encodeSegment(value) {
return encodeURIComponent(String(value || '').trim())
}
export function homePath(query = '') {
const normalized = String(query || '').trim()
return normalized ? `/?q=${encodeURIComponent(normalized)}` : '/'
}
export function templatesPath(query = '') {
const normalized = String(query || '').trim()
return normalized ? `/templates?q=${encodeURIComponent(normalized)}` : '/templates'
}
export function loginPath(redirect = '') {
const normalized = String(redirect || '').trim()
return normalized ? `/login?redirect=${encodeURIComponent(normalized)}` : '/login'
}
export function topicPath(topicId) {
return `/topics/${encodeSegment(topicId)}`
}
export function editorNewPath(topicId) {
return `/editor/${encodeSegment(topicId)}/new`
}
export function editorPath(topicId, tierListId, { preview = false } = {}) {
const base = `/editor/${encodeSegment(topicId)}/${encodeSegment(tierListId)}`
return preview ? `${base}?preview=1` : base
}
export function shareEditorPath(topicId, tierListId) {
return `/share/editor/${encodeSegment(topicId)}/${encodeSegment(tierListId)}`
}
export function mePath() {
return '/me'
}
export function favoritesPath() {
return '/favorites'
}
export function followingFeedPath() {
return '/following'
}
export function commentsPath() {
return '/comments'
}
export function profilePath() {
return '/profile'
}
export function userProfilePath(userId) {
return `/users/${encodeSegment(userId)}`
}