Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On a post, the "next" and "previous" blog post doesn't ignore posts with "redirect" #78

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions components/blog/BlogListModelByYear.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
class="no-underline"
:to="{
path: `/blog/${inThatYear[0]}`,
query: { q: q ? q : undefined },
}"
>
<h2 class="my-4 font-serif text-2xl italic">{{ inThatYear[0] }}</h2>
Expand Down Expand Up @@ -76,7 +75,6 @@
}
export interface Props {
contents: INuxtContentResult[]
q: string
showYear: boolean
}
export default Vue.extend<Data, Methods, Computed, Props>({
Expand All @@ -86,10 +84,6 @@
type: Array,
default: () => [],
},
q: {
type: String,
default: '',
},
showYear: {
type: Boolean,
default: true,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions content/blog/2009/08/inexis-net-2004-sur-flickr.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 9 additions & 8 deletions lib/model/content/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,11 @@ export const isNuxtContentResult = (

export const queryNuxtContent = async (
$content: Context['$content'],
route: Context['route'],
year?: string,
month?: string,
): Promise<INuxtContentResult[]> => {
let contents: INuxtContentResult[] = []
const { query = {} as Context['route']['query'] } = route
let { q = '' } = query
q = typeof q === 'string' ? q : ''
let db: INuxtContentInstance
/**
* Bookmarks:
* - https://github.com/techfort/LokiJS/wiki/Query-Examples#find-queries
Expand All @@ -155,7 +152,14 @@ export const queryNuxtContent = async (
* - http://localhost:3000/_content/blog?deep=true
* - http://localhost:3000/_content/blog?deep=true&created_defined=asdf
*/
const db = $content('blog', { deep: true })
if (year && month) {
db = $content('blog', year, month, { deep: true })
} else if (year) {
db = $content('blog', year, { deep: true })
} else {
db = $content('blog', { deep: true })
}
db = db
.sortBy('createdAt', 'desc')
.only([
'createdAt',
Expand All @@ -171,9 +175,6 @@ export const queryNuxtContent = async (
])

contents = await db.fetch()
contents = contents.filter((a) =>
findExcludingRedirectPredicate(a as INuxtContentResult),
)

return contents
}
Expand Down
1 change: 0 additions & 1 deletion pages/blog/_year/_month/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
class="my-10"
:prev="prev"
:next="next"
style="display: none"
/>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions pages/blog/_year/_month/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@
components: {
'blog-list-model-by-year': BlogListModelByYear,
},
async asyncData({ $content, route, params }) {
async asyncData({ $content, params }) {
let contents: INuxtContentIndexResult[] = []
try {
contents = await queryNuxtContent(
$content,
route,
params.year,
params.month,
)
Expand Down
4 changes: 2 additions & 2 deletions pages/blog/_year/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
components: {
'blog-list-model-by-year': BlogListModelByYear,
},
async asyncData({ $content, route, params }) {
async asyncData({ $content, params }) {
let contents: INuxtContentIndexResult[] = []
try {
contents = await queryNuxtContent($content, route, params.year)
contents = await queryNuxtContent($content, params.year)
} catch (_) {
// ..
}
Expand Down
4 changes: 2 additions & 2 deletions pages/blog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
components: {
'blog-list-model-by-year': BlogListModelByYear,
},
async asyncData({ $content, route }) {
async asyncData({ $content }) {
let contents: INuxtContentIndexResult[] = []
contents = await queryNuxtContent($content, route)
contents = await queryNuxtContent($content)
return {
contents,
pageTitle: 'Blog',
Expand Down
3 changes: 2 additions & 1 deletion static/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@
/blog/2010/01/le-manifeste-open-cloud-pour-standardiser-linformatique-%c2%abdans-les-nuages%c2%bb/ /blog/2010/01/le-manifeste-open-cloud-pour-standardiser-info-nuagique/ 301
/blog/2010/02/realisation-dune-application-dechange-de-cadeau-avec-red-lagence-le-«club-echangiste»-2009/ /blog/2010/02/realisation-dune-application-dechange-de-cadeau-avec-red-lagence/ 301
/blog/2010/02/realisation-dune-application-dechange-de-cadeau-avec-red-lagence-le-%c2%abclub-echangiste%c2%bb-2009/ /blog/2010/02/realisation-dune-application-dechange-de-cadeau-avec-red-lagence/ 301
/blog/2024/03/managing-email-aliases-with-protonmail-and-simplelogin-to-sort-automatically-into-inbox-folders-based-local-part/ /blog/2024/03/managing-email-aliases-with-protonmail-automatic-sorting/ 301
/blog/2013/07/i-am-joining-w3c-to-work-on-the-webplatform-project/ /blog/2013/08/i-am-joining-w3c-to-work-on-the-webplatform-project/ 301
/blog/2013/07/i-am-joining-w3c-to-work-on-the-webplatform-project-2/ /blog/2013/08/i-am-joining-w3c-to-work-on-the-webplatform-project/ 301
/blog/2024/03/managing-email-aliases-with-protonmail-and-simplelogin-to-sort-automatically-into-inbox-folders-based-local-part/ /blog/2024/03/managing-email-aliases-with-protonmail-automatic-sorting/ 301
#
# PAGES THAT HAPPENED TO HAVE MANY URLS FOR THE SAME ARTICLE BECAUSE OF FLOCK BROWSER ----------
#
Expand Down
Loading