cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              <header class="site-header">
  <div class="site-title">
    A Serverless Blog
  <div class="site-subtitle">
    All the code that powers this blog is right here. 

<main class="site-wrap">

  <div id="articles-list">
    <div class="articles-container" />
  <article id="article-whole" class="article-whole start-hidden" >
              * {
  box-sizing: border-box;

.site-header {
  border-top: 1rem solid #556CF6;
  background: #26232d;
  padding: 2rem;
  position: relative;
.site-title {
  font-size: 2rem;
  letter-spacing: 3px;
.site-subtitle {
  font-style: italic;
  opacity: 0.5;
.sign-in-button {
  position: absolute;
  top: 1rem;
  right: 1rem;

.site-wrap {
  padding: 2rem;

.article-block {
  max-width: 650px;
  margin: 0 auto 2rem;
  background: #403E4F;
  padding: 2rem;
  box-shadow: 0.25rem 0.25rem 1.3rem rgba(0, 0, 0, 0.33);
time {
  display: block;
  padding: 0.25rem 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.25rem;
  background: linear-gradient(
    to right,
  font-size: 0.75rem;
.article-body {
  color: #9e9fa8;

.article-whole {
  max-width: 850px;
  margin: 0 auto;

body {
  margin: 0;
  background: #323041;
  color: white;
  font-family: 'PT Serif', serif;
  line-height: 1.4;
h1, h2, h3, h4, h5, h6,
.site-title {
  font-family: 'Barlow Semi Condensed', sans-serif;
  text-transform: uppercase;
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 1rem 0;
  letter-spacing: 0.1rem;
  line-height: 1;
h1 {
  font-size: 3.0rem;
  letter-spacing: 0.1rem;
a {
  color: #8b9bff;
  font-weight: bold;
  border-bottom: 1px solid;
  text-decoration: none;
  padding: 0.25rem 0.5rem;  
a svg {
  fill: currentcolor;
  vertical-align: bottom;
a:focus {
  background: rgba(0, 0, 0, 0.33);

.start-hidden {
  display: none;
              var blog_api_url = 'https://us-central1-duncan-131.cloudfunctions.net/posts';
var posts_list = document.getElementById('articles-list');
var post_full = document.getElementById('article-whole');
var posts_container = posts_list.querySelector('.articles-container');

var loadJsonFromFirebase = function(url, callback) {
    var xhr = new XMLHttpRequest();
    xhr.addEventListener("load", function () {
    xhr.open("GET", url);

var getQueryParam = function(param) {
  let params = window.location.search.substr(1);
  params = params.split("&");
  let paramList = {};
  for (let i = 0; i < params.length; i++) {
    let tmp = params[i].split("=");
    paramList[tmp[0]] = decodeURI(tmp[1]);
  return paramList[param];

// hide the individual post and show the list of posts
const showListClick = (e) => {
  // hide the single post
  // show the full list

// handle selecting the links in the list
const showPostClick = (e) => {
  let post_id = e.target.dataset.post;

  if (post_id) {
    // load the post from ajax call
    loadJsonFromFirebase(blog_api_url + '/' + post_id, function(data) {
      let ts = new Date(data.created);
      let div = document.createElement('div');
      div.innerHTML = `
        <div class="article-body">
      post_full.replaceChild(div, post_full.firstChild);

      // hide the full list
      // show the single post

//document.getElementById('post-view-all').addEventListener('click', showListClick);
posts_list.addEventListener('click', showPostClick);

loadJsonFromFirebase(blog_api_url, function(data) {
  let list = document.createElement('div');
  Object.keys(data).forEach(function(key) {
    let ts = new Date(data[key].created);
    list.innerHTML += `<article class="article-block">
      <div class="excerpt">
        <p>${data[key].content.substr(0, 150)}...</p>
      <a data-post="${key}">Read Post</a>
  posts_container.insertBefore(list, posts_container.firstChild);

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................