diff --git a/assets/js/page.js b/assets/js/page.js new file mode 100644 index 00000000..714b5d20 --- /dev/null +++ b/assets/js/page.js @@ -0,0 +1,106 @@ +var liked_page = false + +if (typeof auth !== 'undefined') { + var id = oid ? oid.replaceAll("/", "-") : oid + var viewed = localStorage.getItem(id); + + if (!viewed) { + auth.signInAnonymously() + .then(() => { + var docRef = db.collection('views').doc(id) + localStorage.setItem(id, true); + docRef.get().then((doc) => { + if (doc.exists) { + db.collection('views').doc(id).update({ + views: firebase.firestore.FieldValue.increment(1) + }); + } else { + db.collection('views').doc(id).set({ views: 1 }) + } + }).catch((error) => { + console.log("Error getting document:", error); + }); + }) + .catch((error) => { + var errorCode = error.code; + var errorMessage = error.message; + console.error(errorCode, errorMessage) + }); + } + + var id_likes = oid_likes ? oid_likes.replaceAll("/", "-") : oid_likes + var liked = localStorage.getItem(id_likes); + + if (liked) { + liked_page = true + document.querySelectorAll("span[id='likes_button_heart']")[0].style.display = "" + document.querySelectorAll("span[id='likes_button_emtpty_heart']")[0].style.display = "none" + document.querySelectorAll("span[id='likes_button_text']")[0].innerText = "" + } + +} + +function like_article(id_likes) { + auth.signInAnonymously() + .then(() => { + var docRef = db.collection('likes').doc(id_likes) + docRef.get().then((doc) => { + liked_page = true + localStorage.setItem(id_likes, true); + document.querySelectorAll("span[id='likes_button_heart']")[0].style.display = "" + document.querySelectorAll("span[id='likes_button_emtpty_heart']")[0].style.display = "none" + document.querySelectorAll("span[id='likes_button_text']")[0].innerText = "" + if (doc.exists) { + db.collection('likes').doc(id_likes).update({ + likes: firebase.firestore.FieldValue.increment(1) + }); + } else { + db.collection('likes').doc(id_likes).set({ likes: 1 }) + } + }).catch((error) => { + console.log("Error getting document:", error); + }); + }) + .catch((error) => { + var errorCode = error.code; + var errorMessage = error.message; + console.error(errorCode, errorMessage) + }); +} + +function remove_like_article(id_likes) { + auth.signInAnonymously() + .then(() => { + var docRef = db.collection('likes').doc(id_likes) + docRef.get().then((doc) => { + liked_page = false + localStorage.removeItem(id_likes); + document.querySelectorAll("span[id='likes_button_heart']")[0].style.display = "none" + document.querySelectorAll("span[id='likes_button_emtpty_heart']")[0].style.display = "" + document.querySelectorAll("span[id='likes_button_text']")[0].innerText = "\xa0Like" + if (doc.exists) { + db.collection('likes').doc(id_likes).update({ + likes: firebase.firestore.FieldValue.increment(-1) + }); + } else { + db.collection('likes').doc(id_likes).set({ likes: 0 }) + } + }).catch((error) => { + console.log("Error getting document:", error); + }); + }) + .catch((error) => { + var errorCode = error.code; + var errorMessage = error.message; + console.error(errorCode, errorMessage) + }); +} + +function process_article() { + var id_likes = oid_likes ? oid_likes.replaceAll("/", "-") : oid_likes + if (!liked_page) { + like_article(id_likes) + } else { + remove_like_article(id_likes) + } +} \ No newline at end of file diff --git a/config/_default/params.toml b/config/_default/params.toml index 6444d411..6ff9d52a 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -15,6 +15,8 @@ enableCodeCopy = true # mainSections = ["section1", "section2"] # robots = "" +#defaultBackgroundImage = "IMAGE.jpg" # used as default for background images + [header] layout = "basic" # valid options: basic, fixed @@ -83,6 +85,24 @@ enableCodeCopy = true [taxonomy] showTermCount = true + #showHero = true + #heroStyle = "background" # valid options: basic, big, background, thumbAndBackground + showBreadcrumbs = false + #showViews = false + #showLikes = false + #showTableOfContents = true + #cardView = false + +[term] + #showHero = true + #heroStyle = "background" # valid options: basic, big, background, thumbAndBackground + showBreadcrumbs = false + #showViews = false + #showLikes = false + #showTableOfContents = true + #groupByYear = false + #cardViewScreenWidth = false + #cardView = false [firebase] # apiKey = "XXXXXX" diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 55137936..3943b16e 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -15,6 +15,8 @@ enableCodeCopy = true mainSections = ["docs"] # robots = "" +defaultBackgroundImage = "/img/iceland.jpg" + [header] layout = "fixed" # valid options: basic, fixed @@ -82,6 +84,24 @@ mainSections = ["docs"] [taxonomy] showTermCount = true + showHero = true + heroStyle = "background" # valid options: basic, big, background, thumbAndBackground + showBreadcrumbs = false + showViews = true + showLikes = true + showTableOfContents = true + +[term] + showHero = true + heroStyle = "background" # valid options: basic, big, background, thumbAndBackground + showBreadcrumbs = false + showViews = true + showLikes = true + showTableOfContents = true + groupByYear = false + cardView = false + cardViewScreenWidth = false + [firebase] apiKey = "AIzaSyB5tqlqDky77Vb4Tc4apiHV4hRZI18KGiY" diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 67825b07..a66ee656 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -193,6 +193,21 @@ Many of the article defaults here can be overridden on a per article basis by sp | `list.cardViewScreenWidth` | `false` | Enhance the width of card galleries in lists to take the full width available. | | `sitemap.excludedKinds` | `["taxonomy", "term"]` | Kinds of content that should be excluded from the generated `/sitemap.xml` file. Refer to the [Hugo docs](https://gohugo.io/templates/section-templates/#page-kinds) for acceptable values. | | `taxonomy.showTermCount` | `true` | Whether or not the number of articles within a taxonomy term is displayed on the taxonomy listing. | +| `taxonomy.showHero` | `false` | Whether the thumbnail image will be shown as a hero image within each taxonomy page. | +| `taxonomy.heroStyle` | _Not set_ | Style to display the hero image, valid options are: `basic`, `big`, `background`, `thumbAndBackground`. | +| `taxonomy.showBreadcrumbs` | `false` | Whether or not breadcrumbs are displayed in the taxonomy header. | +| `taxonomy.showViews` | `false` | Whether or not article views are displayed. This requires firebase integrations to be enabled, look below. | +| `taxonomy.showLikes` | `false` | Whether or not article likes are displayed. This requires firebase integrations to be enabled, look below. | +| `taxonomy.showTableOfContents` | `false` | Whether or not the table of contents is displayed on taxonomies. | +| `term.showHero` | `false` | Whether the thumbnail image will be shown as a hero image within each term page. | +| `term.heroStyle` | _Not set_ | Style to display the hero image, valid options are: `basic`, `big`, `background`, `thumbAndBackground`. | +| `term.showBreadcrumbs` | `false` | Whether or not breadcrumbs are displayed in the term header. | +| `term.showViews` | `false` | Whether or not article views are displayed. This requires firebase integrations to be enabled, look below. | +| `term.showLikes` | `false` | Whether or not article likes are displayed. This requires firebase integrations to be enabled, look below. | +| `term.showTableOfContents` | `false` | Whether or not the table of contents is displayed on terms. | +| `term.groupByYear` | `false` | Whether or not articles are grouped by year on term pages. | +| `term.cardView` | `false` | Display lists as a gallery of cards. | +| `term.cardViewScreenWidth` | `false` | Enhance the width of card galleries in lists to take the full width available. | | `firebase.apiKey` | _Not set_ | Firebase apiKey, required to integrate against Firebase. Check [this page]({{< ref "firebase-views" >}}) for a guide on how to integrate Firebase into Blowfish. | | `firebase.authDomain` | _Not set_ | Firebase authDomain, required to integrate against Firebase. Check [this page]({{< ref "firebase-views" >}}) for a guide on how to integrate Firebase into Blowfish. | | `firebase.projectId` | _Not set_ | Firebase projectId, required to integrate against Firebase. Check [this page]({{< ref "firebase-views" >}}) for a guide on how to integrate Firebase into Blowfish. | diff --git a/exampleSite/content/tags/advanced/_index.md b/exampleSite/content/tags/advanced/_index.md index 04a98ff0..02f65b03 100644 --- a/exampleSite/content/tags/advanced/_index.md +++ b/exampleSite/content/tags/advanced/_index.md @@ -1,5 +1,5 @@ --- -title: advanced +title: Advanced --- This is the advanced tag. Just like other listing pages in Blowfish, you can add custom content to individual taxonomy terms and it will be displayed at the top of the term listing. :rocket: diff --git a/exampleSite/content/tags/advanced/featured.png b/exampleSite/content/tags/advanced/featured.png new file mode 100644 index 00000000..81dda1a9 Binary files /dev/null and b/exampleSite/content/tags/advanced/featured.png differ diff --git a/exampleSite/resources/_gen/images/tags/advanced/featured_hu61945c9a50a7e783444cb54fb71dc68a_650977_1200x0_resize_box_3.png b/exampleSite/resources/_gen/images/tags/advanced/featured_hu61945c9a50a7e783444cb54fb71dc68a_650977_1200x0_resize_box_3.png new file mode 100644 index 00000000..5a6e38bc Binary files /dev/null and b/exampleSite/resources/_gen/images/tags/advanced/featured_hu61945c9a50a7e783444cb54fb71dc68a_650977_1200x0_resize_box_3.png differ diff --git a/exampleSite/resources/_gen/images/tags/featured_huc648350f543f5a6da75f60f86e4aecc9_625096_1200x0_resize_box_3.png b/exampleSite/resources/_gen/images/tags/featured_huc648350f543f5a6da75f60f86e4aecc9_625096_1200x0_resize_box_3.png new file mode 100644 index 00000000..1675d73b Binary files /dev/null and b/exampleSite/resources/_gen/images/tags/featured_huc648350f543f5a6da75f60f86e4aecc9_625096_1200x0_resize_box_3.png differ diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 0919d81c..a487f601 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -36,120 +36,12 @@ {{ .Content | emojify }} + {{ $jsPage := resources.Get "js/page.js" }} + {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint "sha512" }} + {{ if gt .Pages 0 }} @@ -168,9 +60,7 @@ {{ end }} {{ end }} - - - + {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} {{ if $.Params.groupByYear | default ($.Site.Params.list.groupByYear | default true) }}