diff --git a/src/components/StackedNote.vue b/src/components/StackedNote.vue index 02613c0..3c5c2f6 100644 --- a/src/components/StackedNote.vue +++ b/src/components/StackedNote.vue @@ -35,6 +35,6 @@ export default defineComponent({ .stacked-note { text-align: left; border-left: 1px solid rgba(18, 19, 58, 0.2); - padding-left: 1rem; + padding: 0 1rem; } diff --git a/src/components/WelcomeWorld.vue b/src/components/WelcomeWorld.vue new file mode 100644 index 0000000..b7e6506 --- /dev/null +++ b/src/components/WelcomeWorld.vue @@ -0,0 +1,16 @@ + + + + + diff --git a/src/hooks/useForm.hook.ts b/src/hooks/useForm.hook.ts new file mode 100644 index 0000000..7e9b56e --- /dev/null +++ b/src/hooks/useForm.hook.ts @@ -0,0 +1,28 @@ +import { ref } from '@vue/reactivity' +import { useRouter } from 'vue-router' + +export const useForm = () => { + const userInput = ref('') + const repoInput = ref('') + const { push } = useRouter() + + const submit = () => { + if (!userInput.value || !repoInput.value) { + return + } + + push({ + name: 'Home', + params: { + user: userInput.value, + repo: repoInput.value + } + }) + } + + return { + userInput, + repoInput, + submit + } +} diff --git a/src/hooks/useMarkdown.hook.ts b/src/hooks/useMarkdown.hook.ts index 343177a..48b10e9 100644 --- a/src/hooks/useMarkdown.hook.ts +++ b/src/hooks/useMarkdown.hook.ts @@ -1,6 +1,5 @@ import MarkdownIt from 'markdown-it' import markdownItClass from '@toycode/markdown-it-class' -// import sanitizeHtml from 'sanitize-html' const md = new MarkdownIt().use(markdownItClass, { h1: ['title', 'is-1'], diff --git a/src/hooks/useNote.hook.ts b/src/hooks/useNote.hook.ts index 27fd9a5..a9ac489 100644 --- a/src/hooks/useNote.hook.ts +++ b/src/hooks/useNote.hook.ts @@ -13,12 +13,9 @@ const sanitizePath = (path: string) => { return decodeURIComponent(path) } -export const useNote = (user: string, repo: string) => { +export const useNote = (user?: string, repo?: string) => { const { push } = useRouter() - const { readme, notFound, tree } = useRepo(user, repo) - const { listenToClick } = useLinks('note-display') const { query } = useRoute() - const stackedNotes = ref( query.stackedNotes ? Array.isArray(query.stackedNotes) @@ -27,6 +24,17 @@ export const useNote = (user: string, repo: string) => { : [] ) + if (!user || !repo) { + return { + readme: ref(null), + notFound: ref(true), + stackedNotes + } + } + + const { readme, notFound, tree } = useRepo(user, repo) + const { listenToClick } = useLinks('note-display') + const unsubscribe = noteEventBus.addEventBusListener( ({ path, currentNoteSHA }) => { const currentFile = tree.value.find((file) => file.sha === currentNoteSHA) @@ -68,7 +76,11 @@ export const useNote = (user: string, repo: string) => { const newStackedNotes = getStackedNotes() push({ - name: 'Note', + name: 'Home', + params: { + user, + repo + }, query: { stackedNotes: newStackedNotes } diff --git a/src/router/router.ts b/src/router/router.ts index 7a9b6a1..ddce5f0 100644 --- a/src/router/router.ts +++ b/src/router/router.ts @@ -4,20 +4,15 @@ import Home from '@/views/Home.vue' const routes: Array = [ { - path: '/', + path: '/:user?/:repo?', name: 'Home', + props: true, component: Home }, { path: '/about', name: 'About', component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue') - }, - { - path: '/note/:user/:repo', - name: 'Note', - props: true, - component: () => import(/* webpackChunkName: "note" */ '@/views/Note.vue') } ] diff --git a/src/views/Home.vue b/src/views/Home.vue index feb846f..b2e098b 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,31 +1,80 @@ diff --git a/src/views/Note.vue b/src/views/Note.vue deleted file mode 100644 index 4c85b70..0000000 --- a/src/views/Note.vue +++ /dev/null @@ -1,51 +0,0 @@ - - -