diff --git a/script.ts b/script.ts index 84fce2d..fe4ec98 100644 --- a/script.ts +++ b/script.ts @@ -41,4 +41,3 @@ const searchResult = await search(movieDB, { term: 'Chr', }) -console.log(searchResult) diff --git a/src/components/StudyChapter.svelte b/src/components/StudyChapter.svelte index 6d80e69..d0620e1 100644 --- a/src/components/StudyChapter.svelte +++ b/src/components/StudyChapter.svelte @@ -5,7 +5,7 @@ import SvelteMarkdown from 'svelte-markdown' import { user } from '@/state/user' - import { books, versions } from '@/constants' + import { books } from '@/constants' import { createAlert } from '@/services/alert' import Button from '@/components/Button.svelte' import { draft, studyMode } from '@/state/study' @@ -15,10 +15,11 @@ import { formatName } from '@/utils/chapter' import { DEFAULT_NOTE, searchName } from '@/constants' import { sendCreateNote, sendNoteToUpdate } from '@/state/notes' + import { version } from '@/state/bible' /** @type {string} */ - export let version = 'rv1960' + export let versionRead = 'rv1960' /** @type {string} */ export let book = 'genesis' @@ -37,7 +38,7 @@ let hasError = false let selectBook = false let selectChapter = false - let selectVersion = false + let selectversionRead = false /** @type {import('./Passage.svelte').PassageInfo} */ let info = { @@ -73,14 +74,14 @@ chapters = bookInfo.chapters if (chapter > chapters) { chapter = 1 - goto(`/chapter/${version}/${searchName(book)}/${chapter}`) + goto(`/read/${versionRead}/${searchName(book)}/${chapter}`) } } chapters = bookInfo.chapters loading = true const resp = await fetch( - `https://bible-api.deno.dev/api/${version === '' ? 'rv1960' : version}/book/${searchName( + `https://bible-api.deno.dev/api/${versionRead === '' ? 'rv1960' : versionRead}/book/${searchName( book )}/${chapter}` ) @@ -105,32 +106,32 @@ /** * @param {string} book * @param {number} chapter - * @param {string} version + * @param {string} versionRead */ - async function handleChange(book, chapter, version) { + async function handleChange(book, chapter, versionRead) { localStorage.setItem( 'bookmark', JSON.stringify({ - version, + versionRead, chapter, book }) ) - goto(`/chapter/${version}/${searchName(book)}/${chapter}`) + goto(`/read/${versionRead}/${searchName(book)}/${chapter}`) info = await getData() } /** * @param {string|number} value - * @param {'version'|'book'|'chapter'} prop + * @param {'versionRead'|'book'|'chapter'} prop */ function updateData(value, prop) { loading = true switch (prop) { - case 'version': + case 'versionRead': if (typeof value === 'string') { - version = value - selectVersion = false + versionRead = value + selectversionRead = false } break case 'book': @@ -146,7 +147,7 @@ } break } - handleChange(book, chapter, version).then() + handleChange(book, chapter, versionRead).then() } /** @@ -186,7 +187,7 @@ } function getCurrentPage() { - return `${$page.url.origin}/chapter/${version}/${searchName(book)}/${chapter}` + return `${$page.url.origin}/read/${versionRead}/${searchName(book)}/${chapter}` } /** @@ -257,7 +258,7 @@ /** - * @param {'book'|'chapter'|'version'} selector + * @param {'book'|'chapter'|'versionRead'} selector */ function unSelect(selector) { switch (selector) { @@ -267,8 +268,8 @@ case 'chapter': selectChapter = !selectChapter break - case 'version': - selectVersion = !selectVersion + case 'versionRead': + selectversionRead = !selectversionRead break } } @@ -289,32 +290,32 @@
-
(selectVersion = false)}> -

Version

+
(selectversionRead = false)}> +

versionRead

- {#if selectVersion} + {#if selectversionRead}
    - {#each versions as v} + {#each versionReads as v} + -
+ +
+ +
+ + + +
+
{#if loading } diff --git a/src/constants.ts b/src/constants.ts index 0aeffcd..39ac839 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -67,6 +67,78 @@ export const books = [ 'Apocalipsis' ] +export const oldTestament = [ + 'Genesis', + 'Exodo', + 'Levitico', + 'Numeros', + 'Deuteronomio', + 'Josue', + 'Jueces', + 'Rut', + '1-Samuel', + '2-Samuel', + '1-Reyes', + '2-Reyes', + '1-Cronicas', + '2-Cronicas', + 'Esdras', + 'Nehemias', + 'Ester', + 'Job', + 'Salmos', + 'Proverbios', + 'Eclesiastes', + 'Cantares', + 'Isaias', + 'Jeremias', + 'Lamentaciones', + 'Ezequiel', + 'Daniel', + 'Oseas', + 'Joel', + 'Amos', + 'Abdias', + 'Jonas', + 'Miqueas', + 'Nahum', + 'Habacuc', + 'Sofonias', + 'Hageo', + 'Zacarias', + 'Malaquias', +] + +export const newTestament = [ + 'Mateo', + 'Marcos', + 'Lucas', + 'Juan', + 'Hechos', + 'Romanos', + '1-Corintios', + '2-Corintios', + 'Galatas', + 'Efesios', + 'Filipenses', + 'Colosenses', + '1-Tesalonicenses', + '2-Tesalonicenses', + '1-Timoteo', + '2-Timoteo', + 'Tito', + 'Filemon', + 'Hebreos', + 'Santiago', + '1-Pedro', + '2-Pedro', + '1-Juan', + '2-Juan', + '3-Juan', + 'Judas', + 'Apocalipsis' +] + export const VERSIONS = { rv1960: 'Reina Valera 1960', rv1995: 'Reina Valera 1995', diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 6cf1faf..6f99723 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -9,6 +9,7 @@ import OpenSource from '@/components/icons/OpenSource.svelte' import Lightning from '@/components/icons/Lightning.svelte' import ZeroAdds from '@/components/icons/ZeroAdds.svelte' + import { goto } from '$app/navigation'
@@ -36,7 +37,7 @@ class="min-lg:place-items-start m-4 flex font-bold max-lg:justify-around max-lg:text-xl max-md:justify-center max-md:gap-4 max-sm:flex-col max-sm:place-content-center max-sm:align-middle lg:gap-3 lg:text-2xl" > + + + +
+ +
+ + {#if testament === 'old'} + + {:else} + + {/if} +
+ + + + + diff --git a/src/routes/chapters/[book]/+page.js b/src/routes/chapters/[book]/+page.js new file mode 100644 index 0000000..60e47ff --- /dev/null +++ b/src/routes/chapters/[book]/+page.js @@ -0,0 +1,14 @@ +/** @type {import('./$types').PageLoad} */ +export function load({ params }) { + return { + params + } + // if (params.slug === 'hello-world') { + // return { + // title: 'Hello world!', + // content: 'Welcome to our blog. Lorem ipsum dolor sit amet...' + // } + // } + + // throw error(404, 'Not found') +} diff --git a/src/routes/chapters/[book]/+page.svelte b/src/routes/chapters/[book]/+page.svelte new file mode 100644 index 0000000..e69c930 --- /dev/null +++ b/src/routes/chapters/[book]/+page.svelte @@ -0,0 +1,86 @@ + + + + +
+
+

+ Capitulos del libro {formatName(data.params.book)} +

+
+ +
+ +
+ {#if chapters > 0} + {#each { length: chapters } as _, i} + + {/each} + {/if} +
+
+
+ + + + + diff --git a/src/routes/chapter/[version]/[book]/[chapter]/+page.js b/src/routes/read/[version]/[book]/[chapter]/+page.js similarity index 100% rename from src/routes/chapter/[version]/[book]/[chapter]/+page.js rename to src/routes/read/[version]/[book]/[chapter]/+page.js diff --git a/src/routes/chapter/[version]/[book]/[chapter]/+page.svelte b/src/routes/read/[version]/[book]/[chapter]/+page.svelte similarity index 100% rename from src/routes/chapter/[version]/[book]/[chapter]/+page.svelte rename to src/routes/read/[version]/[book]/[chapter]/+page.svelte diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index 9e6a002..a77b692 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -47,7 +47,7 @@ * @param {number} chapter */ function urlVerse(book, chapter) { - const endpoint = `https://bible-study.vercel.app/chapter/${ + const endpoint = `https://bible-study.vercel.app/read/${ $versionSearch.url }/${book.toLowerCase()}/${chapter}` return endpoint @@ -73,7 +73,6 @@ loadingResults.set(false) }) .catch((e) => { - console.log('fetch cancelado') console.error(e) loadingResults.set(false) }) diff --git a/src/routes/versions/+page.svelte b/src/routes/versions/+page.svelte new file mode 100644 index 0000000..7c6ec5f --- /dev/null +++ b/src/routes/versions/+page.svelte @@ -0,0 +1,34 @@ + + + +
+

Versiones

+ +
    + {#each versions as versionBible} + + {/each} +
+
+ diff --git a/src/services/api/auth.js b/src/services/api/auth.js index cb09add..0bf8f81 100644 --- a/src/services/api/auth.js +++ b/src/services/api/auth.js @@ -37,6 +37,28 @@ export async function singIn(data) { return response } +/** + * + * @param {string} book + * @returns {Promise<{ + * name: string + * abrev: string + * chapters: number + * testament: string + * }| undefined>} + */ +export async function getInfoBook(book) { + const resp = await fetch(`https://bible-api.deno.dev/api/book/${book}`) + + if (!resp.ok) { + return + } + + const info = await resp.json() + + return info +} + /** * @param {any} data * @returns {Promise} @@ -72,7 +94,7 @@ export async function singUp(data) { return response } -export async function signOut () { +export async function signOut() { await fetch(`${API_BASE_URL}/auth/logout`, { headers: { 'Content-Type': 'application/json' }, credentials: 'include' @@ -85,7 +107,7 @@ export async function signOut () { }) } -export async function updateUserInfo () { +export async function updateUserInfo() { try { const res = await fetch(`${API_BASE_URL}/user`, { credentials: 'include' diff --git a/src/state/bible.js b/src/state/bible.js new file mode 100644 index 0000000..3c795cf --- /dev/null +++ b/src/state/bible.js @@ -0,0 +1,6 @@ + +import { writable } from 'svelte/store' + +export const version = writable('') +export const book = writable('') +export const chapter = writable(0) diff --git a/src/utils/chapter.js b/src/utils/chapter.js index 51fcda3..0f80364 100644 --- a/src/utils/chapter.js +++ b/src/utils/chapter.js @@ -10,11 +10,11 @@ export function goToChapter() { const version = bkmark.version const chapter = bkmark.chapter - goto(`/chapter/${version}/${book}/${chapter}`) + goto(`/read/${version}/${book}/${chapter}`) return } - goto('/chapter/rv1960/Genesis/1') + goto('/read/rv1960/Genesis/1') } /**