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

              
                <!-- <!DOCTYPE html> -->
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>Google Cloud/G Suite Content Blog</title>

  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  <link rel="stylesheet" href="https://codepen.io/rramona2/pen/BVdMLe.css">

  <!--   <style>
    @import url('https://fonts.googleapis.com/css?family=Roboto');
  </style> -->
  <!--   <link rel="stylesheet" href="css/main.css"> -->
</head>

<body>
  <header>
    <img src="https://lh3.googleusercontent.com/n8Rz-84sfQM9KDJXsX9eFpmMdmHES66uI7_yLADsn_cZXrF4tx4RtZomp41gUtQQ7ByegEJ33FL-xdezFdOPwAh1J-GNfk6Ttg2LyEqerpf7x8c90wH6z-P2hww8L2zFPPXNAfFTBr1hS4Gwr8_2Cf0R9361ll-mp5Qj08DL-Lcd7GTSK9Li51s1BMFbR2-aW0Azzki2rtZwQ8HvsP88a2SDNOU0ruX0HHLqrGyeFYGayhHizsXH4LuMEgegw6G79APkWnhMBCm-hpST5zyB9Jz_ckslLcNqE9x12tye1MPSm6DVS6wJ2qbdJpnPftmAQAwAybPCJ60WyKr-gUwd6w-jDnj8KKJnPdC6yUGe-Wr1ITkju1G3Fm86tY1JkTTYSGb9oHEBukiGfWVySXKadYLIl9ziAGXNpC55Sx8ZXIAcqsOXr2KeTwZr6etXD4Rg5zK6DKB5OdswyaehfvQDLnQkLvE09dEBlxWUKs0nf0Uo_IycGuzSV_xkXud4pnRO4doEEp3V30xCu9TKgF2Hwj45dGMMTbT9DXuwnaEaYTswNY00d1Xhgb7ERLtG1ety-Fr1D764OD7tv4ztgb1jJyh5phfPM-b5UN7htGo=w269-h267-no">
    <h1>Website Content Management App</h1>
  </header>
  <main>
    <div class="information">
      This is an example application that manages the content for a fitness & nutrition website
    </div>
    <nav id="filter"></nav>
    <div id="container"></div>
    <div id="notice"></div>
  </main>
  <footer>
    <img src="https://lh3.googleusercontent.com/O1hsaZYfnZiRnhXFiHwrdNG8NuhTgSYdUj-yszdwYIfgLegVQGOj3XUEXUo21I_nb8lj4__4MfYZ279zUQSQbUmd-ZYrggg3E8-lG5vDV4KbeP4pbo4ZgyXKkM_0KcmlPV6N6D_5Myb9-2ZvOWFZGF7ac6k6WsGc4FZzZwpPBFAFdjoIaDIbq-31VWc546LCWWvJ8cfVEfEEJFbXcUhUM14L-w5T0HEfD765C7FTj0S2LgioVArztWkpLuL8f0TBTJZalbYA1xNphLO8HFxl7HkrqTWRsoJcaOuqllk-J0nESD0aejtwpWXcff3SsV6VQ_7gQzwZylCyVWnVmQ0XWtA8fg_UECEV15oh3xznMu5cpGAz-fwLooE9g5nweJSITIZIxahZHLkSB09uKmE4r1HFLEd3mS0a-JbxCu_3qrAAHOK96EqcF3gtLSgJYPg1oX0G2-e6-RCZ2QDFLW34iwXRIAcsOXEfe32TE8JgEHeI9xEOPcitkXsNkzKW7CJlnjhdZoCquds1BRsBdOXa2U4Oe9Cy6VcE4pQve1DYHHx0x8mudPlvHaqCMBQNEU0geYzLOF2sQC-UJZzImBJhBjTmT2GOzXwbDoTebfA=w351-h179-no">

  </footer>
  <script src="https://codepen.io/rramona2/pen/BVdMLe.js"></script>
  <script>
    document.addEventListener('DOMContentLoaded', app.init);
  </script>
</body>

</html>
              
            
!

CSS

              
                html,
body {
  background: #f8f8f8;
  color: #2d3436;
  font-family: "Roboto", sans-serif;
  font-size: normal;
  line-height: 1.5;
}

a {
  color: #1a1a1a;
  border-bottom: solid 1px #b2bec3;
  text-decoration: none;
}

a:hover {
  border-color: #1a1a1a;
}

img {
  max-width: 100%;
}

button {
  border-radius: 5px;
  border: solid 1px #b2bec3;
  cursor: pointer;
  display: inline-block;
  padding: 0.2em 0.5em;
}

button:hover {
  background: #2d3436;
  border-color: #b2bec3;
}

button.selected {
  border-color: #2d3436;
}

header,
main,
footer {
  padding: 4em 5%;
}

header {
  background: #2d3436;
  color: white;
  text-align: center;
}

header h1 {
  margin-bottom: 0;
}

.information {
  background: #2d3436;
  margin-bottom: 4em;
  padding: 2em;
}

nav {
  margin-bottom: 4em;
}

nav span {
  display: block;
  font-size: 0.9em;
  margin-bottom: 1em;
}

nav button {
  margin: 0 0.5em 1em 0;
}

article {
  margin-bottom: 6em;
}

.article-details {
  border-bottom: solid 2px #dfe6e9;
  font-size: 0.9em;
  padding-bottom: 1em;
}

.article-details div:first-child {
  margin-bottom: 0.5em;
}

#notice {
  font-weight: bold;
  text-align: center;
}

footer {
  background: #2d3436;
  color: #2d3436;
  text-align: center;
}

footer p {
  margin-top: 0;
}

@media only screen and (min-width: 992px) {
  .article-details {
    align-items: center;
    display: flex;
    justify-content: space-between;
  }

  .article-details div:first-child {
    margin-bottom: 0;
  }

  header,
  main,
  footer {
    padding: 4em 25%;
  }
}

@media only screen and (min-width: 1200px) {
  header,
  main,
  footer {
    padding: 4em 30%;
  }
}

/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */
html {
  line-height: 1.15;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
}
article,
aside,
footer,
header,
nav,
section {
  display: block;
}
h1 {
  font-size: 2em;
  margin: 0.67em 0;
}
figcaption,
figure,
main {
  display: block;
}
figure {
  margin: 1em 40px;
}
hr {
  box-sizing: content-box;
  height: 0;
  overflow: visible;
}
pre {
  font-family: monospace, monospace;
  font-size: 1em;
}
a {
  background-color: transparent;
  -webkit-text-decoration-skip: objects;
}
abbr[title] {
  border-bottom: none;
  text-decoration: underline;
  text-decoration: underline dotted;
}
b,
strong {
  font-weight: inherit;
}
b,
strong {
  font-weight: bolder;
}
code,
kbd,
samp {
  font-family: monospace, monospace;
  font-size: 1em;
}
dfn {
  font-style: italic;
}
mark {
  background-color: #ff0;
  color: #000;
}
small {
  font-size: 80%;
}
sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}
sub {
  bottom: -0.25em;
}
sup {
  top: -0.5em;
}
audio,
video {
  display: inline-block;
}
audio:not([controls]) {
  display: none;
  height: 0;
}
img {
  border-style: none;
}
svg:not(:root) {
  overflow: hidden;
}
button,
input,
optgroup,
select,
textarea {
  font-family: sans-serif;
  font-size: 100%;
  line-height: 1.15;
  margin: 0;
}
button,
input {
  overflow: visible;
}
button,
select {
  text-transform: none;
}
[type="reset"],
[type="submit"],
button,
html [type="button"] {
  -webkit-appearance: button;
}
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner,
button::-moz-focus-inner {
  border-style: none;
  padding: 0;
}
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring,
button:-moz-focusring {
  outline: 1px dotted ButtonText;
}
fieldset {
  padding: 0.35em 0.75em 0.625em;
}
legend {
  box-sizing: border-box;
  color: inherit;
  display: table;
  max-width: 100%;
  padding: 0;
  white-space: normal;
}
progress {
  display: inline-block;
  vertical-align: baseline;
}
textarea {
  overflow: auto;
}
[type="checkbox"],
[type="radio"] {
  box-sizing: border-box;
  padding: 0;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
  height: auto;
}
[type="search"] {
  -webkit-appearance: textfield;
  outline-offset: -2px;
}
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}
::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}
details,
menu {
  display: block;
}
summary {
  display: list-item;
}
canvas {
  display: inline-block;
}
template {
  display: none;
}
[hidden] {
  display: none;
} /*# sourceMappingURL=normalize.min.css.map */

              
            
!

JS

              
                const app = (function() {
  const API_BASE =
    "https://script.google.com/a/rlrdata.com/macros/s/AKfycbxc0Te8upSsH06q1epVUuyziade3fPU1pz_AWi45w/exec";
  const API_KEY = "fitness";
  const CATEGORIES = ["general", "workout plan", "nutrition plan", "other"];

  const state = { activePage: 1, activeCategory: null };
  const page = {};

  function init() {
    page.notice = document.getElementById("notice");
    page.filter = document.getElementById("filter");
    page.container = document.getElementById("container");

    _buildFilter();
    _getNewPosts();
  }

  function _getNewPosts() {
    page.container.innerHTML = "";
    _getPosts();
  }

  function _getPosts() {
    _setNotice("Loading posts");

    fetch(_buildApiUrl(state.activePage, state.activeCategory))
      .then(response => response.json())
      .then(json => {
        if (json.status !== "success") {
          _setNotice(json.message);
        }

        _renderPosts(json.data);
        _renderPostsPagination(json.pages);
      })
      .catch(error => {
        _setNotice("Unexpected error loading posts");
      });
  }

  function _buildFilter() {
    page.filter.appendChild(_buildFilterLink("no filter", true));

    CATEGORIES.forEach(function(category) {
      page.filter.appendChild(_buildFilterLink(category, false));
    });
  }

  function _buildFilterLink(label, isSelected) {
    const link = document.createElement("button");
    link.innerHTML = _capitalize(label);
    link.classList = isSelected ? "selected" : "";
    link.onclick = function(event) {
      let category = label === "no filter" ? null : label.toLowerCase();

      _resetActivePage();
      _setActiveCategory(category);
      _getNewPosts();
    };

    return link;
  }

  function _buildApiUrl(page, category) {
    let url = API_BASE;
    url += "?key=" + API_KEY;
    url += "&page=" + page;
    url += category !== null ? "&category=" + category : "";

    return url;
  }

  function _setNotice(label) {
    page.notice.innerHTML = label;
  }

  function _renderPosts(posts) {
    posts.forEach(function(post) {
      const article = document.createElement("article");
      article.innerHTML = `
				<h2>${post.title}</h2>
				<div class="article-details">
					<div>By ${post.author} on ${_formatDate(post.timestamp)}</div>
					<div>Posted in ${post.category}</div>
				</div>
				${_formatContent(post.content)}
			`;
      page.container.appendChild(article);
    });
  }

  function _renderPostsPagination(pages) {
    if (pages.next) {
      const link = document.createElement("button");
      link.innerHTML = "Load more posts";
      link.onclick = function(event) {
        _incrementActivePage();
        _getPosts();
      };

      page.notice.innerHTML = "";
      page.notice.appendChild(link);
    } else {
      _setNotice("No more posts to display");
    }
  }

  function _formatDate(string) {
    return new Date(string).toLocaleDateString("en-GB");
  }

  function _formatContent(string) {
    return string
      .split("\n")
      .filter(str => str !== "")
      .map(str => `<p>${str}</p>`)
      .join("");
  }

  function _capitalize(label) {
    return label.slice(0, 1).toUpperCase() + label.slice(1).toLowerCase();
  }

  function _resetActivePage() {
    state.activePage = 1;
  }

  function _incrementActivePage() {
    state.activePage += 1;
  }

  function _setActiveCategory(category) {
    state.activeCategory = category;

    const label = category === null ? "no filter" : category;
    Array.from(page.filter.children).forEach(function(element) {
      element.classList =
        label === element.innerHTML.toLowerCase() ? "selected" : "";
    });
  }

  return {
    init: init
  };
})();

              
            
!
999px

Console