How to Build a Portfolio Site Using Vue and Cosmic JS


In this tutorial, I am going to show you how to create a portfolio site using Vue and Cosmic JS.

The portfolio site we are going to build will have 4 pages there are home, technologies, projects, and open sources. This site also will have 3 object types there are profiles, technologies, and projects.


Setup bucket

To create the bucket, login to Cosmic JS and click add new bucket

Select start from scratch


Setup profiles object type

Click add object type menu and put Profile on singular name textbox

Add the metafields below:

1. Introduction (plain text input)

2. Image (image/file)

3. About (HTML text area)

4. Facebook (plain text input)

5. Twitter (plain text input)

6. Github (plain text input)

7. Footer (plain text input)


Setup technologies object type

Click add object type menu and put Technology on singular name textbox

Add the image metafield (image/file)


Setup projects object type

Click Add object type menu and put Projects on singular textbox

Add the metafields below:

1. Short description (plain text input)

2. Image (image/file)

3. Technologies (multiple object relationship), select Technologies object type

4. URL (plain text input)

5. Open source (radio buttons), add two options there are Yes and No


Dependencies

This site use Vue to create single page application. For the router it use Vue Router. It also use ES6 so it need Babel and Webpack for the module bundler. For template engine it use Jade and Stylus as CSS preprocessor.


Setup index.html

In this file we include Twitter Bootstrap, Font Awesome, Cosmic JS configuration and the core Javascript. Line 12 is where the Vue app is mounted.


Setup script.js

This site use Vue Router for the routing, you can see the routes on line 12 – 17. On line 6 – 10 to import the required component.


Setup App.vue

This file contains router view component, footer, and global style. The template is on line 1 – 19. The components required by App.vue is imported on line 22 – 23. Line 42 – 49  to call Cosmic JS API when the component is mounted and the style is on line 54 – 77.


Setup MainMenu.vue

This file is for the main menu of the site. The template is on line 1 – 11 and in this template it use router link component from Vue Router to create the anchor so the active class will be include automatically. The style is on line 13 – 30.


Setup Home.vue

This file contains image and about text. The template is on line 1 – 15. Line 18 to include Cosmic JS. Line 33 – 42 to call Cosmic JS API when the component is mounted. And the style is on line 46 – 55.


Setup Technologies.vue

This file shows the contents from technology object type. The template is on line 1 – 15. Line 18 to include Cosmic JS. Line 33 – 42 to call Cosmic JS API when the component is mounted. And the style is on line 46 – 55.


Setup Projects.vue and OpenSources.vue

These two files show data from project object type, the different is Project.vue shows data from project object type when the metafield_value of open_source metafield_key is Yes and for OpenSources.vue is No. The template is on line 1 – 16. Line 18 to include Cosmic JS. Line 28 – 34 to render the technologies array and on line 38 – 48 to call Cosmic JSAPI with metafield_key is  open_source and metafield_value is No for projects page and metafield_value is Yes for open source page. The style is on line 53 – 69.


Conclusion

This is the portfolio site built using Vue and Cosmic JS. I hope you like the tutorial and hopefully will help you.

Was this article helpful?

Thank you! Your input helps us improve our articles and resources. If you have any other questions or comments, please contact support.

You may also like


In this tutorial, I'll show you how to deploy your Gatsby Blog to Netlify and trigger automatic rebuilds on content edits using Cosmic JS Webhooks.
This application was mainly inspired by Offerup, Letgo, and Craigslist. Like Craigslist, LetGo allows you to buy and sell items locally, which means you don’t have to deal with the hassles of shipping like you would on eBay or Amazon. With 30 million users, it is more popular than OfferUp...
Cosmic JS makes it easy to manage content for your Vue.js applications. In this blog we'll quickstart a Vue.js RPG Adventure Game using the Cosmic CLI. Our game, "Enter The Cosmos", is a turn-based, RPG style game built using Vue.js, Node.js and Cosmic JS.
Exporting Cosmic JS-powered data to CSV is easy with this new extension 🚀
In this blog we'll quickstart a React Native Cross-Platform Blog using the Cosmic JS CLI. This app is three apps in one: Web, iOS and Android app all with content powered by Cosmic JS. Go to the GitHub repo to see the iOS and Android app share the same React Native codebase.
When you're laser focused on writing songs, getting the most out of your studio time, and finding gigs, you can't be bothered with setting up a static site for your band or dealing with abstruse CMS systems.