From a77da34cd8e696c16e99422a1b4761a82990526b Mon Sep 17 00:00:00 2001 From: Ricardo Date: Wed, 16 Dec 2020 16:19:14 +0000 Subject: [PATCH] feat: authors & newsletter form --- src/.vuepress/config/authors.js | 45 ++++++++++++ src/.vuepress/plugins/pageData.js | 23 +++++- .../theme/components/base/Avatar.vue | 6 ++ .../theme/components/blog/ActiveTags.vue | 7 +- .../theme/components/blog/NewsletterForm.vue | 11 ++- .../theme/components/blog/PostAuthor.vue | 6 +- .../theme/components/blog/PostMeta.vue | 6 +- .../theme/components/mixins/Author.vue | 4 + src/.vuepress/theme/layouts/Blog.vue | 31 +++----- src/.vuepress/theme/util/blogUtils.js | 69 ++++++++++-------- src/_assets/avatars/alan-shaw.jpg | Bin 0 -> 21202 bytes src/_assets/avatars/david-dias.jpg | Bin 0 -> 26118 bytes src/_assets/avatars/dietrich-ayala.jpg | Bin 0 -> 35911 bytes src/_assets/avatars/jenn-turner.jpg | Bin 0 -> 76596 bytes src/_assets/avatars/jessie-clayburgh.jpg | Bin 0 -> 23028 bytes src/_assets/avatars/juan-benet.jpg | Bin 0 -> 20079 bytes src/_assets/avatars/lidel.jpg | Bin 0 -> 25020 bytes src/_assets/avatars/whyrusleeping.jpg | Bin 0 -> 25211 bytes src/_blog/110-go-ipfs-0-7-0/README.md | 1 + 19 files changed, 143 insertions(+), 66 deletions(-) create mode 100644 src/_assets/avatars/alan-shaw.jpg create mode 100644 src/_assets/avatars/david-dias.jpg create mode 100644 src/_assets/avatars/dietrich-ayala.jpg create mode 100644 src/_assets/avatars/jenn-turner.jpg create mode 100644 src/_assets/avatars/jessie-clayburgh.jpg create mode 100644 src/_assets/avatars/juan-benet.jpg create mode 100644 src/_assets/avatars/lidel.jpg create mode 100644 src/_assets/avatars/whyrusleeping.jpg diff --git a/src/.vuepress/config/authors.js b/src/.vuepress/config/authors.js index 2362a92d..d8f02283 100644 --- a/src/.vuepress/config/authors.js +++ b/src/.vuepress/config/authors.js @@ -34,4 +34,49 @@ module.exports = new Map([ twitter: '@jesseclayburgh', }, ], + [ + 'jenn-turner', + { + name: 'Jenn Turner', + avatar: 'jenn-turner.jpg', + twitter: '@jennwrites', + }, + ], + [ + 'dietrich-ayala', + { + name: 'Dietrich Ayala', + avatar: 'dietrich-ayala.jpg', + twitter: '@dietrich', + }, + ], + [ + 'david-dias', + { + name: 'David Dias', + avatar: 'david-dias.jpg', + twitter: '@daviddias', + }, + ], + [ + 'whyrusleeping', + { + name: 'whyrusleeping', + avatar: 'whyrusleeping.jpg', + }, + ], + [ + 'lidel', + { + name: 'lidel', + avatar: 'lidel.jpg', + }, + ], + [ + 'alan-shaw', + { + name: 'Alan Shaw', + avatar: 'alan-shaw.jpg', + }, + ], ]) diff --git a/src/.vuepress/plugins/pageData.js b/src/.vuepress/plugins/pageData.js index 170aa2f6..d98c7634 100644 --- a/src/.vuepress/plugins/pageData.js +++ b/src/.vuepress/plugins/pageData.js @@ -1,17 +1,36 @@ +const { chalk } = require('@vuepress/shared-utils') const slug = require('slug') module.exports = (options, context) => ({ extendPageData($page) { - const { frontmatter } = $page + const { frontmatter, _filePath } = $page + const { authors } = options // author config const authorName = frontmatter.author + const authorAvatarUrl = frontmatter.avatarUrl + if (typeof authorName === 'string') { const authorKey = slug(authorName, { lower: true }) // setup author stub to keep templates happy - const author = { name: authorName } + let author = { name: authorName } + if (authors.has(authorKey)) { + author = authors.get(authorKey) + } else if (authorAvatarUrl) { + author.avatarUrl = authorAvatarUrl + } else { + console.error( + `${chalk.red( + 'error' + )} Could not find a configured author for ${chalk.cyan( + authorName + )} used in ${_filePath}. You need to add a new key in ${chalk.cyan( + '.vuepress/config/authors.js' + )} or set a frontmatter value for ${chalk.cyan('avatarUrl')}` + ) + } // setup the page author object frontmatter.author = author frontmatter.authorKey = authorKey diff --git a/src/.vuepress/theme/components/base/Avatar.vue b/src/.vuepress/theme/components/base/Avatar.vue index 6b8a37d0..f05d2d18 100644 --- a/src/.vuepress/theme/components/base/Avatar.vue +++ b/src/.vuepress/theme/components/base/Avatar.vue @@ -15,6 +15,12 @@ ctx="_assets/avatars/" :alt="name" /> + diff --git a/src/.vuepress/theme/components/blog/ActiveTags.vue b/src/.vuepress/theme/components/blog/ActiveTags.vue index 548953db..652374e6 100644 --- a/src/.vuepress/theme/components/blog/ActiveTags.vue +++ b/src/.vuepress/theme/components/blog/ActiveTags.vue @@ -12,14 +12,13 @@ > (newest first) of {{ activeCategory }} - for " + for {{ text }} + >"{{ text }}" - " with tag{{ numberOfPosts > 1 ? 's' : '' }}:with tag{{ activeTags.length > 1 ? 's' : '' }}: