Skip to content

Instantly share code, notes, and snippets.

//Sua API
let postsApi = 'http://meusite.com/wp-json/wp/v2/posts'
//Jovemnerd
//let postsApi = 'https://jovemnerd.com.br/wp-json/wp/v2/posts'
//B9
//let postsApi = 'https://www.b9.com.br/wp-json/wp/v2/posts/'
let posts = Http
const Http = {
inicia: (postsAPI) => Http._pega(postsAPI),
_pega: (postsAPI) => {
fetch(postsAPI,{method:'get'})
.then(res => res.json())
.then(posts => Http._monta(posts), err => {
let template = `
<span style="color:red">
Esse servidor não fornece permissão para consumo de sua API
</span>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Aplicação</title>
</head>
<body>
<div class="posts"></div>
<script src="modules/Http.js"></script>
<?php
$query = new WP_Query([“posts_per_page” => -1]);
while ( $query->have_posts() ): $query->the_post();
//acesso as informações
endwhile; wp_reset_postdata();
@allanferreira
allanferreira / index.html
Created May 9, 2016 22:11
Minha versão do BEM HTML com outras classes na estrutura
<div class="btn clear--fix">button</div>
<div class="btn--color-red float--left">button</div>
<div class="btn--size-large text--center">button</div>
<div class="btn--color-red--size-large is--enable">button</div>
@allanferreira
allanferreira / index.html
Created May 9, 2016 22:07
BEM HTML na versão de Jordan Lewis com outras classes na estrutura
<div class="btn clear -fix">button</div>
<div class="btn -color-red float -left">button</div>
<div class="btn -size-large text -center">button</div>
<div class="btn -color-red -size-large is -enable">button</div>
@allanferreira
allanferreira / style.styl
Created May 9, 2016 22:01
BEM na versão de Jordan Lewis com stylus
.btn
background #ccc
color #000
width 100px
padding 10px 20px
font-size 16px
text-align center
.-color-red
color red
.-size-large
@allanferreira
allanferreira / index.html
Last active May 9, 2016 22:04
BEM HTML na versão de Jordan Lewis
<div class="btn">button</div>
<div class="btn -color-red">button</div>
<div class="btn -size-large">button</div>
<div class="btn -color-red -size-large">button</div>
@allanferreira
allanferreira / style.styl
Created May 9, 2016 21:45
Minha versão do BEM com stylus
.btn
background #ccc
color #000
width 100px
padding 10px 20px
font-size 16px
text-align center
/[class*="--color-red"]
@extend .btn
color red
@allanferreira
allanferreira / style.styl
Created May 9, 2016 19:54
BEM escrito com stylus
.btn
background #ccc
color #000
width 100px
padding 10px 20px
font-size 16px
text-align center
&--color-red
color #f00
&--size-large