Master to develop backport (#48)

* WEBSITE-1582 - News from contentful

* WEBSITE-1582 - Removed a couple of unneeded checks
This commit is contained in:
Grade-Zero
2019-06-21 13:11:36 +10:00
committed by Alex Shteinikov
parent 6d26b9abe7
commit 3b6899d97f
3 changed files with 52 additions and 3 deletions
+46
View File
@@ -0,0 +1,46 @@
(function () {
if (typeof window.$ === "undefined") {
return;
}
function getPrefixURL(type) {
switch(type) {
case "blog":
return "https://go.tiny.cloud/blog/";
break;
default:
return "https://go.tiny.cloud/blog/";
}
}
function setResultToNewsBar(latest) {
$(".tiny-news-text").text(latest.text);
var newsLink = $(".tiny-news-link");
newsLink.attr("href", latest.url);
newsLink.text(latest.urlText);
var prefix = $(".tiny-news-prefix");
prefix.text("TINY " + latest.type.toUpperCase());
prefix.attr("href", getPrefixURL(latest.type));
}
function fetchLatestNews() {
var url = "https://cdn.jsdelivr.net/npm/contentful@latest/dist/contentful.browser.min.js";
$.getScript( url, function() {
var client = contentful.createClient({
space: "sn6g75ou164i",
accessToken: "BptrxEYsjeOYo1RSx_-qF_UVkn5HDs_MeHpG1g0wJx4"
});
client.getEntries({
order: "-sys.createdAt",
limit: 1,
content_type: "news"
}).then(function(entries) {
setResultToNewsBar(entries.items[0].fields);
}).catch(function(err) {
console.log(err);
});
});
}
$(document).ready(fetchLatestNews);
})();
+1
View File
@@ -141,6 +141,7 @@
<script>
{% include js/my-account-button.js %}
{% include js/notifications.js %}
</script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
+5 -3
View File
@@ -1,14 +1,15 @@
<div class="tiny-news-docs">
<div>
<a href="https://go.tiny.cloud/blog/"
data-marketing="tiny-news-blog-link">
data-marketing="tiny-news-blog-link"
class="tiny-news-prefix">
TINY BLOG
</a>
&gt;
Important changes to Tiny Cloud pricing
<span class="tiny-news-text">Important changes to Tiny Cloud pricing</span>
&gt;
<a href="https://go.tiny.cloud/blog/important-changes-to-tiny-cloud-pricing-metric/"
data-marketing="tiny-news-pricing-blog-link">
data-marketing="tiny-news-pricing-blog-link" class="tiny-news-link">
Find out more
</a>
</div>
@@ -20,6 +21,7 @@
</div>
</div>
<style type="text/css">
.tiny-news-docs {