@gudhub/ssg-web-components-library 1.0.78 → 1.0.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/ssg-web-components-library",
3
- "version": "1.0.78",
3
+ "version": "1.0.79",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -7,10 +7,16 @@ class BlogBanner extends GHComponent {
7
7
 
8
8
  constructor() {
9
9
  super();
10
+ const homepageAttr = this.getAttribute('data-homepage');
11
+ try {
12
+ this.homepageObj = homepageAttr && JSON.parse(homepageAttr);
13
+ } catch (e) {
14
+ console.warn('Invalid data-homepage JSON:', `data-homepage='{"title": "Головна", "link": "/"}'`);
15
+ this.homepageObj = { title: 'Головна', link: '/' };
16
+ }
10
17
  }
11
18
 
12
19
  async onServerRender() {
13
-
14
20
  this.config = initBlogConfig(window.getConfig().componentsConfigs.blog_config[0]);
15
21
 
16
22
  let url = new URL(window.location.href);
@@ -40,10 +46,7 @@ class BlogBanner extends GHComponent {
40
46
  breadcrumbsTitle.innerHTML = this.json.title;
41
47
 
42
48
  this.breadcrumbs = JSON.stringify([
43
- {
44
- title: 'Головна',
45
- link: '/'
46
- },
49
+ this.homepageObj,
47
50
  {
48
51
  title: breadcrumbsTitle.innerText
49
52
  }
@@ -2,8 +2,8 @@
2
2
  <div class="button text" onclick="openList()">${config.general_settings.categories}</div>
3
3
  <div class="list_wrapper">
4
4
  <ul class="categories_list flex-wrapper">
5
- <li ${url == '/blog/' ? 'class="active"' : ''}>
6
- <a href="/blog/" class="text btn empty">${config.general_settings.all_articles_button}</a>
5
+ <li ${url == `${allArticlesButtonLink}` ? 'class="active"' : ''}>
6
+ <a href="${allArticlesButtonLink}" class="text btn empty">${config.general_settings.all_articles_button}</a>
7
7
  </li>
8
8
  ${
9
9
  categories.reduce((acc, category, index) => {
@@ -28,6 +28,7 @@ class CategoriesList extends GHComponent {
28
28
  this.categories = this.categories.categories;
29
29
  this.url = new URL (window.location.href);
30
30
  this.url = this.url.searchParams.get('path');
31
+ this.allArticlesButtonLink = this.config.general_settings.all_articles_button_link || '/blog/'
31
32
  super.render(html);
32
33
  }
33
34
 
@@ -42,12 +42,12 @@ class CategoryBanner extends GHComponent {
42
42
 
43
43
  this.breadcrumbs = JSON.stringify([
44
44
  {
45
- "title": "Головна",
46
- "link": "/"
45
+ "title": this.config.breadcrumbs.homepage || "Головна",
46
+ "link": this.config.breadcrumbs.homepageLink || "/"
47
47
  },
48
48
  {
49
- "title": this.config.breadcrumbs.blog,
50
- "link": "/blog/"
49
+ "title": this.config.breadcrumbs.blog || "Блог",
50
+ "link": this.config.breadcrumbs.blogLink || "/blog/"
51
51
  },
52
52
  {
53
53
  "title": this.title
@@ -110,7 +110,7 @@ class CommentsComponent extends GHComponent {
110
110
  }
111
111
 
112
112
  if (comment.name && comment.text) {
113
- const { api_app_id } = window.getConfig().componentsConfigs.chapters.blog || window.getConfig().chapters.blog;
113
+ const { api_app_id } = window.getConfig().chapters.blog;
114
114
  const response = await fetch(`https://gudhub.com/api/services/prod/api/${api_app_id}/add-comment`, {
115
115
  method: 'POST',
116
116
  headers: {