<template>
  <div>
    <!--<div v-html="etiquetteGuideContent.content" class="mx-auto history-section"></div>-->
    <div v-if="pageContent.length">
      <div v-html="getPageContent()"></div>
    </div>
    <PostScriptBlog />
    <FooterComponent />
  </div>
</template>
<script>
const baseUrl = process.env.VUE_APP_BASE_URL;
import PostScriptBlog from "@/components/retailer/home/PostScriptBlog";
import FooterComponent from "@/components/layout/footer/FooterComponent";
import { goToCategoryPage } from "@/services/util.service";
export default {
  name: "AboutUs",
  components: {
    PostScriptBlog,
    FooterComponent
  },
  computed: {
     pageContent: function() {
      return this.$store.state.layout.pageContent;
    },
    etiquetteGuideContent: function() {
      return this.$store.state.block.one;
    },
     canonical: function() {
      return this.$route.meta.canonical;
    }, 
  },
  data: () => ({
    image: require("@/assets/c4aa164d9b01387a88228c67620f7faf861b5544.png"),
  }),
  metaInfo() {
        return {
            link: [
                {rel: 'canonical', href:`${this.canonical ? window.location.href.split('?')[0] : baseUrl }`}
            ] 
        }
  },
  methods: {
     getPageContent() {
      if (this.pageContent.length) {
        let data = this.pageContent.filter(element => {
          return element.identifier === "about-us";
        });
        if (data.length > 0) {
          let path = data[0].content;
          var div = document.createElement("div");
          div.innerHTML = path;
          let imgSrcUrls = div.getElementsByTagName("img");
          for (let i = 0; i < imgSrcUrls.length; i++) {
            let urlValue = imgSrcUrls[i].getAttribute("src");
            if (urlValue) {
              imgSrcUrls[i].setAttribute(
                "src",
                this.imageBasePathUrl() +
                  "/media/" +
                  imgSrcUrls[i].src
                    .replace(window.location.href, "")
                    .replace(window.location.origin, "")
                    .replace(/%22%7D%7D/g, "")
                    .replace(/%7B%7B/g, "")
                    .replace(/%20url=%22/g, "")
                    .replace("media", "")
              );
            }
          }
          return div.innerHTML;
        }
      }
    },
     imageBasePathUrl() {
      return process.env.VUE_APP_IMAGE_CATEGORY_PATH_URL;
    },
     routeToPage(pageName) {
       if (pageName == "CategoryPage") {
        let vm = this;
        goToCategoryPage(vm, "stationery", null, null, 10);
      }
    },
    initialLink() {
      return process.env.VUE_APP_HOME_PAGE_URL;
    },
    goToPage(pageLink) {
      window.location.replace(this.initialLink()+pageLink);
      //} else {
      //window.open(routeSecond, "_self");
      //}
    },
  },

  created() {
    // this.$store.dispatch("block/fetchEtiquetteGuide", this.blockId);
  }
};
</script>
<style src="./about_us.scss" lang="scss" /> 