Master to develop backport (#48)
* WEBSITE-1582 - News from contentful * WEBSITE-1582 - Removed a couple of unneeded checks
This commit is contained in:
committed by
Alex Shteinikov
parent
6d26b9abe7
commit
3b6899d97f
@@ -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);
|
||||
})();
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
>
|
||||
Important changes to Tiny Cloud pricing
|
||||
<span class="tiny-news-text">Important changes to Tiny Cloud pricing</span>
|
||||
>
|
||||
<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 {
|
||||
|
||||
Reference in New Issue
Block a user