-
- {{ piece }}
+
+ {{ piece.name }}
{{
- resolvedAuthorName.length !== 1 &&
- index !== resolvedAuthorName.length - 1
- ? ', '
- : ''
+ author.length !== 1 && index !== author.length - 1 ? ', ' : ''
}}
@@ -33,22 +27,20 @@
diff --git a/src/.vuepress/theme/layouts/Blog.vue b/src/.vuepress/theme/layouts/Blog.vue
index ad47102d..b48345a2 100644
--- a/src/.vuepress/theme/layouts/Blog.vue
+++ b/src/.vuepress/theme/layouts/Blog.vue
@@ -60,11 +60,13 @@ import LanguageSelector from '@theme/components/base/LanguageSelector'
import { getTags } from '@theme/util/tagUtils'
import { parseProtectedPost, checkItem } from '@theme/util/blogUtils'
import uniq from 'lodash/uniq'
+import uniqBy from 'lodash/uniqBy'
import pick from 'lodash/pick'
import isEqual from 'lodash/isEqual'
+import orderBy from 'lodash/orderBy'
import countly from '../util/countly'
-const defaultCategory = 'Blog post'
+const defaultCategory = { name: 'Blog post', slug: 'blog-post' }
export default {
name: 'BlogIndex',
@@ -95,12 +97,19 @@ export default {
'videoModalCard',
]),
tags() {
- return getTags(this.activeTags, this.publicPages)
+ return getTags(
+ this.tagsList.filter((tag) => this.activeTags.includes(tag.slug)),
+ this.publicPages
+ )
},
publicPages: function () {
let result = []
this.$pagination.pages.forEach((page) => {
- if (this.categoriesList.includes(page.frontmatter.type)) {
+ if (
+ this.categoriesList
+ .map((category) => category.slug)
+ .includes(page.frontmatter.type?.slug)
+ ) {
result = [
...result,
...parseProtectedPost(
@@ -144,7 +153,9 @@ export default {
: this.publicPages.slice(0, this.numberOfPagesToShow)
},
queryProptertyWatchlist() {
- return `${this.activeCategory}|${this.activeTags}|${this.searchedText}|${this.activeAuthor}`
+ return `${JSON.stringify(this.activeCategory)}|${this.activeTags}|${
+ this.searchedText
+ }|${this.activeAuthor}`
},
urlUpdate() {
return this.$route.query
@@ -177,25 +188,20 @@ export default {
}
if (data) {
- tagsArray.push(
- uniq(
- data
- .filter((subPage) => subPage.tags)
- .map((subPage) => subPage.tags)
- .flat(2)
- )
- )
+ data.forEach((subPage) => {
+ if (subPage.tags) {
+ tagsArray.push(...subPage.tags)
+ }
+ })
}
if (author) {
- authorsArray.push(
- author.name.split(/,|and|&/).map((author) => author.trim())
- )
+ authorsArray.push(author)
}
})
- categories = uniq(categories, true)
- tagsArray = uniq(tagsArray.flat(2), true)
+ categories = orderBy(uniq(categories, true), 'name')
+ tagsArray = uniqBy(tagsArray.flat(2), 'name')
authorsArray = uniq(authorsArray.flat(2), true)
this.$store.commit('appState/setCategoriesList', [
@@ -225,7 +231,11 @@ export default {
let queryCategory = query.category || ''
- if (queryCategory && !this.categoriesList.includes(queryCategory)) {
+ const filteredCategory = this.categoriesList.find(
+ (category) =>
+ category.slug === queryCategory || category.name === queryCategory
+ )
+ if (queryCategory && !filteredCategory) {
queryCategory = ''
delete newQuery.category
}
@@ -233,7 +243,9 @@ export default {
let queryTags = query.tags ? query.tags.split(',') : []
if (queryTags.length > 0) {
- queryTags = queryTags.filter((tag) => this.tagsList.includes(tag))
+ queryTags = queryTags.filter((queryTag) =>
+ this.tagsList.find((tag) => tag.slug === queryTag)
+ )
if (queryTags.length === 0) {
delete newQuery.tags
@@ -242,7 +254,10 @@ export default {
let queryAuthor = query.author
- if (queryAuthor && !this.authorsList.includes(queryAuthor)) {
+ if (
+ queryAuthor &&
+ !this.authorsList.map((author) => author.slug).includes(queryAuthor)
+ ) {
queryAuthor = ''
delete newQuery.author
}
@@ -255,7 +270,7 @@ export default {
if (queryCategory !== '') {
const categoryTracking = {
- category: queryCategory,
+ category: filteredCategory.name,
method: 'urlQuery',
}
@@ -263,9 +278,9 @@ export default {
}
if (queryTags.length > 0) {
- queryTags.forEach((tag) => {
+ queryTags.forEach((queryTag) => {
const tagTracking = {
- tag: tag,
+ tag: this.tagsList.find((tag) => tag.slug === queryTag).name,
method: 'urlQuery',
}
@@ -294,19 +309,25 @@ export default {
}
this.$store.commit('appState/setActiveTags', queryTags)
- this.$store.commit('appState/setActiveCategory', queryCategory)
+ this.$store.commit(
+ 'appState/setActiveCategory',
+ filteredCategory || queryCategory
+ )
this.$store.commit(
'appState/setSearchedText',
queryText ? queryText.split(',') : []
)
- this.$store.commit('appState/setActiveAuthor', queryAuthor || '')
+ this.$store.commit(
+ 'appState/setActiveAuthor',
+ this.authorsList.find((author) => author.slug === queryAuthor) || ''
+ )
const latestWeeklyPost = this.publicPages
.filter(
(item) =>
item.frontmatter &&
item.frontmatter.tags &&
- item.frontmatter.tags.includes('weekly')
+ item.frontmatter.tags.find((tag) => tag.name === 'weekly')
)
.sort(
(a, b) => new Date(b.frontmatter.date) - new Date(a.frontmatter.date)
@@ -323,8 +344,8 @@ export default {
...this.$route.query,
tags: this.activeTags.join(','),
search: this.searchedText.join(','),
- category: this.activeCategory,
- author: this.activeAuthor,
+ category: this.activeCategory.slug || '',
+ author: this.activeAuthor.slug || '',
}
Object.keys(newQuery).forEach((entry) => {
@@ -333,7 +354,6 @@ export default {
delete newQuery[entry]
}
})
-
this.$router.replace({ query: newQuery }).catch(() => {})
},
blockLazyLoad() {
diff --git a/src/.vuepress/theme/layouts/BlogPost.vue b/src/.vuepress/theme/layouts/BlogPost.vue
index 50d4d681..15f5bce0 100644
--- a/src/.vuepress/theme/layouts/BlogPost.vue
+++ b/src/.vuepress/theme/layouts/BlogPost.vue
@@ -53,6 +53,17 @@ export default {
},
},
mounted() {
+ // redirect routes that are not blog posts (/events, /videos, etc)
+ // to the homepage with the search parameter category
+ if (!this.isVisible && this.$root.$page.frontmatter.type) {
+ const type = this.$root.$page.frontmatter.type
+
+ // path is relative to support ipfs sub path deployments
+ return this.$router.replace({ path: `../?category=${type.slug}` })
+ }
+
+ // redirect any other blog post route that should not be visible
+ // to the 404 page (hidden or scheduled publish posts)
if (!this.isVisible) {
// path to 404 is relative to support ipfs sub path deployments
return this.$router.replace({ path: '../404' })
diff --git a/src/.vuepress/theme/util/blogUtils.js b/src/.vuepress/theme/util/blogUtils.js
index 6acdce26..8af9491f 100644
--- a/src/.vuepress/theme/util/blogUtils.js
+++ b/src/.vuepress/theme/util/blogUtils.js
@@ -2,29 +2,27 @@ export function checkItem({
postType,
tags,
title,
- author = {},
+ author = [],
activeTags = [],
searchedText = [],
activeCategory = '',
- activeAuthor = '',
+ activeAuthor,
}) {
- if (activeCategory && decodeURI(activeCategory) !== postType) {
+ if (activeCategory && activeCategory.slug !== postType.slug) {
return false
}
if (
activeAuthor &&
- ((author.name &&
- !author.name
- .toLowerCase()
- .includes(decodeURI(activeAuthor.toLowerCase()))) ||
- !author.name)
+ ((author.length > 0 &&
+ !author.map((entry) => entry.slug).includes(activeAuthor.slug)) ||
+ author.length === 0)
) {
return false
}
for (let i = 0; i < activeTags.length; i++) {
- if (!tags || !tags.includes(activeTags[i])) {
+ if (!tags || !tags.map((tag) => tag.slug).includes(activeTags[i])) {
return false
}
}
@@ -76,13 +74,11 @@ export function parseProtectedPost(
type: post.frontmatter.type,
date: item.date,
title: item.title,
- author: { name: item.author },
path: item.path,
frontmatter: {
...item,
date: item.date,
title: item.title,
- author: { name: item.author },
path: item.path,
type: post.frontmatter.type,
},
diff --git a/src/.vuepress/theme/util/tagUtils.js b/src/.vuepress/theme/util/tagUtils.js
index 1eb9eb1d..a47cf4a1 100644
--- a/src/.vuepress/theme/util/tagUtils.js
+++ b/src/.vuepress/theme/util/tagUtils.js
@@ -1,4 +1,4 @@
-import isArray from 'lodash/isArray'
+import orderBy from 'lodash/orderBy'
export const getTags = (activeTags, posts) => {
const tags = [...activeTags]
@@ -8,16 +8,14 @@ export const getTags = (activeTags, posts) => {
return
}
- const postTags = isArray(post.frontmatter.tags)
- ? post.frontmatter.tags
- : post.frontmatter.tags.replace(/, /g, ',').split(',')
+ const postTags = post.frontmatter.tags
for (let i = 0; i < postTags.length; i++) {
- if (postTags[i] && !tags.includes(postTags[i])) {
+ if (postTags[i] && !tags.find((tag) => tag.slug === postTags[i].slug)) {
tags.push(postTags[i])
}
}
})
- return tags.sort()
+ return orderBy(tags, 'name')
}