How to Build a Portfolio Site Using Vue and Cosmic

Community Articles
Community Articles How to Build a Portfolio Site Using Vue and Cosmic

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

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 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 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 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. Line 33 – 42 to call Cosmic 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. Line 33 – 42 to call Cosmic 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. Line 28 – 34 to render the technologies array and on line 38 – 48 to call CosmicAPI 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. I hope you like the tutorial and hopefully will help you.

You may also like


This article shows you how to create a blazing fast Gatsby JS blog using Cosmic source plugin. Let’s get started.
One of the largest problems I’ve faced while working on projects is having to deal with integrating content and events into third-party services.It’s time consuming, and as the demands in the application in question grows, so does the mental strain in having to keep up to pace with all the changes
Here we build a progressive web app in React.js with the power of Cosmic. It respond with status 200 and carries data when you disconnected to internet and in Chrome browser (both mobile and desktop) it gives an option to install the app on home screen.
Filtering data is one of the most common feature of any data facing application, wheather it's a fron-end app or a back-end application. The Filter function is used to find records in a table or a dataset that meets certain criteria.
5 Website Boilerplates: React, Node.js, Vue, Nuxt.js and Next.js
Cosmic makes it easy to deploy your websites and applications to the web. You can deploy an app from any git repository to the Cosmic App Server from any Bucket. Cosmic uses Dokku (Docker + Heroku-like deployment) to deploy your app from any GitHub, BitBucket or any other public repo.

Get Started with Cosmic

Build personal projects for free. Add your team at unbeatable prices.
Start Building Talk to Sales