Skip to content

Commit

Permalink
Stashing(client-side search): Remove unused client side search
Browse files Browse the repository at this point in the history
  • Loading branch information
renoirb committed Oct 26, 2024
1 parent bc958e1 commit 2c4ebe0
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 86 deletions.
53 changes: 2 additions & 51 deletions pages/blog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@
v-if="!!$route && $route.params && $route.matched"
:route="$route"
/>
<!-- form
class="justify-self-end sm:w-full position-relative flex items-center justify-center"
@submit.prevent="submit"
>
<label for="search" class="sr-only">Search within blog:</label>
<input
id="search"
v-model="q"
type="search"
autocomplete="off"
name="q"
placeholder="e.g. linux"
class="focus:z-50 focus:shadow-outline w-full px-4 py-2 leading-normal border border-gray-300 rounded"
/>
</form -->
</div>
<div
v-if="
Expand All @@ -36,16 +21,14 @@
<h1>{{ pageTitle }}</h1>
</div>
<div class="pages-blog--parent--bottom">
<nuxt-child :q="q" />
<nuxt-child />
</div>
</section>
</template>

<script lang="ts">
import Vue from 'vue'
export interface Data {
q: string
}
export interface Data {}
export interface Methods {}
export interface Computed {
pageTitle: string
Expand All @@ -55,44 +38,12 @@
components: {
'app-bread-crumb': () => import('@/components/AppBreadCrumb.vue'),
},
data() {
return {
q: '',
}
},
computed: {
pageTitle(): string {
let pageTitle = 'Blog'
const q = this.q
if (q !== '') {
pageTitle += `, search results for «${q`
}
return pageTitle
},
},
watch: {
q: {
immediate: true,
handler(q) {
if (this.$router) {
this.$router
.replace({ query: q !== '' ? { q } : undefined })
.catch(() => {})
}
},
},
},
beforeMount() {
const { query = {} } = this.$route
const { q = '' } = query
this.q = typeof q === 'string' ? q : ''
},
methods: {
submit() {
// if you want to send any data into server before redirection then you can do it here
this.$router.push('/blog?q=' + this.q)
},
},
head() {
const title = this.pageTitle
const out = {
Expand Down
1 change: 0 additions & 1 deletion pages/blog/_year/_month/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<blog-list-model-by-year
:show-year="false"
:contents="contents"
:q="$route && $route.query && $route.query.q"
/>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion pages/blog/_year/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<blog-list-model-by-year
:show-year="false"
:contents="contents"
:q="$route && $route.query && $route.query.q"
/>
</div>
</div>
Expand Down
34 changes: 2 additions & 32 deletions pages/blog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class="body"
:data-count="contents.length"
>
<blog-list-model-by-year :contents="contents" :q="q" />
<blog-list-model-by-year :contents="contents" />
</div>
<rb-notice-box v-if="contents.length > 40" variant="info" lang="en">
<strong slot="header">Apologies for the long list</strong>
Expand Down Expand Up @@ -38,19 +38,11 @@
}
export interface Methods {}
export interface Computed {}
export interface Props {
q: string
}
export interface Props {}
export default Vue.extend<Data, Methods, Computed, Props>({
components: {
'blog-list-model-by-year': BlogListModelByYear,
},
props: {
q: {
type: String,
default: '',
},
},
async asyncData({ $content, route }) {
let contents: INuxtContentIndexResult[] = []
contents = await queryNuxtContent($content, route)
Expand All @@ -60,28 +52,6 @@
}
},
/*
watch: {
q: {
immediate: true,
async handler(val, oldVal) {
let pageTitle = 'Blog'
if (!val) {
this.contents = [] as INuxtContentResult[]
return
}
if (val === oldVal) {
// No change, nothing to do
return
}
if (val !== '') {
pageTitle += `, search results for «${val}»`
}
const contents = await queryNuxtContent(this.$content, this.$route)
this.contents = contents
this.pageTitle = pageTitle
},
},
},
async beforeMount() {
const contents = await queryNuxtContent(this.$content, this.$route)
// This is wrong. Improve. Plz
Expand Down
1 change: 0 additions & 1 deletion pages/blog/tag/_tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
>
<blog-list-model-by-year
:contents="contents"
:q="$route && $route.query && $route.query.q"
/>
</div>
</div>
Expand Down

0 comments on commit 2c4ebe0

Please sign in to comment.