Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <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>
              
            
!

CSS

              
                * {
  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);
}
              
            
!

JS

              
                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

Console