-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Adding serverless blog example #1457
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
Conversation
src/v2/cookbook/serverless-blog.md
Outdated
@@ -0,0 +1,268 @@ | |||
# Create a serverless CMS-Powered Blog Using Vue.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to index this article, here's an example of how to do so:
---
title: Create a Serverless CMS-Powered Blog
type: cookbook
order: 5
---
src/v2/cookbook/serverless-blog.md
Outdated
@@ -0,0 +1,268 @@ | |||
# Create a serverless CMS-Powered Blog Using Vue.js | |||
|
|||
So you've just launched your Vue.js website, congrats! Now you want to add a blog that quickly plugs into your website and you don't want to have to spin up a whole server just to host a Wordpress instance (or any DB-powered CMS for that matter). You want to just be able to add a few Vue.js blog components and some routes and have it all just work, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
picky, but there's an extra space between "few" and "Vue.js"
src/v2/cookbook/serverless-blog.md
Outdated
|
||
So you've just launched your Vue.js website, congrats! Now you want to add a blog that quickly plugs into your website and you don't want to have to spin up a whole server just to host a Wordpress instance (or any DB-powered CMS for that matter). You want to just be able to add a few Vue.js blog components and some routes and have it all just work, right? | ||
|
||
This tutorial will teach you how to do just that. We're going to quickly build a serverless CMS-powered blog with Vue.js. It uses ButterCMS, an API-first CMS that lets you manage content using the ButterCMS dashboard and integrate our content API into your Vue.js app. You can use ButterCMS for new or existing Vue.js projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please link up ButterCMS, i.e.
It uses [ButterCMS](https://buttercms.com/)
src/v2/cookbook/serverless-blog.md
Outdated
This API request fetches your blog posts. Your account comes with one example post which you'll see in the response. | ||
|
||
## Display posts | ||
To display posts we create a simple `/blog` route (using vue-router) in our app and fetch blog posts from the Butter API, as well as a `/blog/:slug` route to handle individual posts. See our [API reference](https://buttercms.com/docs/api/?javascript#blog-posts) for additional options such as filtering by category or author. The response also includes some metadata we'll use for pagination. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to avoid the word "simple" because, depending on the skill level of the reader, it may not be very simple for them.
src/v2/cookbook/serverless-blog.md
Outdated
</template> | ||
``` | ||
|
||
Now our app is pulling all blog posts and we can navigate to individual posts. However, our next/previous post buttons are not working. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to add a screenshot here so that people can visualize what you're referring to
src/v2/cookbook/serverless-blog.md
Outdated
|
||
Now our app is pulling all blog posts and we can navigate to individual posts. However, our next/previous post buttons are not working. | ||
|
||
One thing to note when using routes with params is that when the user navigates from /blog/foo to /blog/bar, the same component instance will be reused. Since both routes render the same component, this is more efficient than destroying the old instance and then creating a new one. However, this also means that the lifecycle hooks of the component will not be called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "however" here would be better served as a tip. Like:
<p class="tip">Be aware, that using the component this way will mean that the lifecycle hooks of the component will not be called. Visit the Vue.js docs...</p>
src/v2/cookbook/serverless-blog.md
Outdated
|
||
Use Butter's APIs for categories, tags, and authors to feature and filter content on your blog. | ||
|
||
See our API reference for more information about these objects: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of "our API" makes this sound like an ad. It's ok to use ButterCMS for an example, but the our here should refer to Vue, not ButterCMS
Overall, its a great start! I think this is a great introduction. This is also easy to follow. There are a couple of major things that need to be changed to get the PR through:
|
@sdras Thanks for the great feedback! I've made your suggested changes but did have one question. Regarding your feedback on "when to avoid this pattern" - could you provide more detail in the context of adding a blog to an application? I could also use a bit more direction on what you're looking for in terms of "Alternative patterns". Would this be an alternate way to add a blog to your Vue.js app? Thanks! |
@jakelumetta good question! You could probably explore such options as Nuxtent, which allow you to use Vue Component inside your markdown files, which allow you to write and process markdown files instead of using a static site generator like jekyll. That would be a good candidate for a quick compare/contrast or at least mention in case people want to know what their options are. |
@sdras Very cool. Wasn't aware of Nuxtent actually, thanks :) I just added an Alternative Pattern section. Let me know your thoughts. |
src/v2/cookbook/serverless-blog.md
Outdated
|
||
That's it! You now have a fully functional serverless blog running in your app. We hope this tutorial was helpful and made your development experience with Vue.js even more enjoyable :) | ||
|
||
## Alternative Pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of pedantic, but we call this section Alternative Patterns for every entry even if it's just one, for consistency :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/v2/cookbook/serverless-blog.md
Outdated
|
||
<p class="tip">Be aware, that using the component this way will mean that the lifecycle hooks of the component will not be called. Visit the Vue.js docs to learn more about [Dynamic Route Matching](https://router.vuejs.org/en/essentials/dynamic-matching.html)</p> | ||
|
||
To fix this we need to simply watch the `$route` object and call `getPost()` when the route changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use the word "simply" because it can be offputting to beginners if a concept doesn't seem that simple to them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
One thing to note when using routes with params is that when the user navigates from /blog/foo to /blog/bar, the same component instance will be reused. Since both routes render the same component, this is more efficient than destroying the old instance and then creating a new one. | ||
|
||
<p class="tip">Be aware, that using the component this way will mean that the lifecycle hooks of the component will not be called. Visit the Vue.js docs to learn more about [Dynamic Route Matching](https://router.vuejs.org/en/essentials/dynamic-matching.html)</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good tip to include, thanks for pointing this out to people
src/v2/cookbook/serverless-blog.md
Outdated
## Display posts | ||
To display posts we create a `/blog` route (using vue-router) in our app and fetch blog posts from the Butter API, as well as a `/blog/:slug` route to handle individual posts. See our [API reference](https://buttercms.com/docs/api/?javascript#blog-posts) for additional options such as filtering by category or author. The response also includes some metadata we'll use for pagination. | ||
|
||
See our API reference for additional options such as filtering by category or author. The response also includes some metadata we'll use for pagination. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this section, you say "our API reference" a few times- please say "the ButterCMS API reference" as you're in the vue docs and "our API reference" should refer to Vue's API reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/v2/cookbook/serverless-blog.md
Outdated
|
||
So you've just launched your Vue.js website, congrats! Now you want to add a blog that quickly plugs into your website and you don't want to have to spin up a whole server just to host a Wordpress instance (or any DB-powered CMS for that matter). You want to just be able to add a few Vue.js blog components and some routes and have it all just work, right? What you're looking for a "serverless" blog that's powered entirely by API's you can consume directly from your Vue.js application. This tutorial will teach you how to do just that, let's dive in! | ||
|
||
We're going to quickly build a serverless CMS-powered blog with Vue.js. It uses [ButterCMS](https://buttercms.com/), an API-first CMS that lets you manage content using the ButterCMS dashboard and integrate our content API into your Vue.js app. You can use ButterCMS for new or existing Vue.js projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You say Serverless here and at the end without any reference or explanation to what is Serverless about it, and why that's important, or how it works. I would either remove that descriptor or spend more time explaining Serverless concepts and why that matters here.
In my opinion, it has little to do with the rest of the article, so I'd just remove the reference for clarity and flow, but it's up to you.
src/v2/cookbook/serverless-blog.md
Outdated
this.getPostsByCategory() | ||
} | ||
``` | ||
## Wrap up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the wrap up section after the alternative patterns section. I don't think you need the part about the feedback and PR, because that's kind of self explanatory, but I could go either way on it :) It's not a bad thing to include.
This is looking great! We're almost there. I left a few more comments, when we've squared those away, I think we'll be good to merge |
@sdras awesome - I've made all of your suggested updates. Thanks for the great editing help. 👍 |
Perfect! Well done. |
PR for #1432
CC @sdras
Looking forward to your feedback!