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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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>
  <div class="site-subtitle">
    All the code that powers this blog is right here. 
  </div>
</header>

<main class="site-wrap">

  <div id="articles-list">
    <div class="articles-container" />
  </div>

</main>
            
          
!
            
              * {
  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,
    #4a4c5a,
    #403E4D
  );
  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:hover,
a:focus {
  background: rgba(0, 0, 0, 0.33);
}
            
          
!
            
              var blog_api_url = 'https://us-central1-duncan-131.cloudfunctions.net/posts';
var posts_list = document.getElementById('articles-list');
var posts_container = posts_list.querySelector('.articles-container');

var loadJsonFromFirebase = function(url, callback) {
    var xhr = new XMLHttpRequest();
    xhr.addEventListener("load", function () {
        callback(JSON.parse(this.response));
    });
    xhr.open("GET", url);
    xhr.send();
};

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">
      <h2>${data[key].title}</h2>
      <time>${ts.toDateString()}</time>
      <div class="excerpt">
        <p>${data[key].content.substr(0, 150)}...</p>
      </div>
      <a href="#${key}" data-post="${key}">Read Post</a>
    </article>`;
  });
  posts_container.insertBefore(list, posts_container.firstChild);
});

            
          
!
999px
Loading ..................

Console