import { apiGet } from '@/lib/api'

import type { WikiPage } from '@/types'


export const fetchWikiPages = async ({ title }: { title: string }) =>
    await apiGet ('/wiki', { params: { title } })


export const fetchWikiPage = async (
    id:           string,
    { version }:  { version?: string },
): Promise<WikiPage> =>
    await apiGet (`/wiki/${ id }`, { params: version ? { version } : { } })


export const fetchWikiPageByTitle = async (
    title:        string,
    { version }:  { version?: string },
): Promise<WikiPage> =>
    await apiGet (`/wiki/title/${ title }`,
		  { params: version ? { version } : { } })
