# Blogs

**Installation of Spurtcommerce blogs Add-On**

**you can install this Add-on through following steps**

step 1: [<mark style="color:blue;">Setup an API (Step By Step)</mark> ](#setup-an-api-step-by-step)to add extension for admin

step 2: [<mark style="color:blue;">Admin setup</mark>](#admin-setup)

step 3: you can easily install admin storefront with [<mark style="color:blue;">store setup</mark><mark style="color:blue;">**.**</mark>](#store-setup) spurtcommerce provides 3 admin storefronts, built with[ <mark style="color:blue;">Angular</mark>](#store-setup)<mark style="color:blue;">,</mark> [<mark style="color:blue;">Flutter</mark> ](#store-setup)and [<mark style="color:blue;">React</mark>](#store-setup)<mark style="color:blue;">.</mark> &#x20;

**About Addon :**

The Installation of Spurtcommerce Blogs will enable the feature of creation of blog articles to the admin. The admin can add various blog articles. When the plugin is installed, the Multi-Vendor eCommerce site becomes ready for the admin to post blog articles and get them displayed for the visitors to read.

**Features:**

* Create categories to map the blog article to make it specific to a particular area or field.&#x20;
* Easily create blog articles.
* &#x20;Provide title and body content for the blog article.
* &#x20;Add a relevant attractive image to the blog article. Then, add meta tags to blog articles to make it SEO friendly and searchable in the search engines.

### [<mark style="color:blue;">Setup an API (Step By Step)</mark>](#setup-an-api-step-by-step)

For setting up the API, you need to execute the following steps:

* Installing an extension&#x20;
* Run the application
* &#x20;Make the build

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

Usually spurcommerce comes packed in a zip, whose name ends in <mark style="color:green;">**"blogs-addOn.zip"**</mark><mark style="color:blue;">.</mark> Extract the zip file, open api folder and open addon folder within that and copy the content of addon folder into the specified path.

&#x20;                                  **Path - \<PROJECT\_ROOT>/addon**

**Step 2 : Run the application**

After you have completed the installation of the above mentioned steps, you can run the application and also view the changes.

```
$ npm start serve
```

Once you execute the above command, add-on file will get integrated into the backend API.

**Step 3 : Make the build**

These are the steps that need to be followed for generating the build.

To run the below command

```
$ npm run build
```

Then latest built files can be deployed into the server.

### [<mark style="color:blue;">Admin Setup</mark>](#admin-setup)

These are the steps that need to be followed to do the front end admin setup.

* Installing an extension&#x20;
* Update the configuration&#x20;
* Module Detail
* &#x20;Run the application&#x20;
* Make the build

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

Usually spurcommerce comes packed in a zip, whose name ends in "blogs-addOn.zip".&#x20;

Extract the zip file and copy the content of admin/add-ons folder into the specified path

**Path -  admin/add-ons**

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.

**update reducer config**

Import below line into the <mark style="color:green;">**add-ons/add-ons-reducer.ts**</mark>

```
  Import below line into the add-ons/add-ons-reducer.ts
   import * as fromBlog from './cms/blogs/core/blogs-reducer/blog.reducer';
 
```

```
 import * as fromBlogCategory from
  './cms/blog-category/core/blog-category-reducer/blog-category.reducer';

```

Add the reducer into the below object

```
   blog: fromBlog.reducer,
                            blogCategory: fromBlogCategory.reducer

```

After adding its looks like below

```
export const AddOnReducers: ActionReducerMap<State> = {
    blog: fromBlog.reducer,
    blogCategory:  fromBlogCategory.reducer
};


```

**Update State Config**

Import below line into the <mark style="color:green;">**add-ons/add-ons-state.ts**</mark>

```
  import { BlogState } from './cms/blogs/core/blogs-store/blog.state';
import { BlogCategoryState } from './cms/blog-category/core/blog-category-store/blog.state';

```

Add the state into the below object

&#x20; blog: BlogState;

&#x20;  blogCategory: BlogCategoryState,

After adding its looks like below

```
export interface AddOnAppState {
    blog: BlogState,
    blogCategory: BlogCategoryState,

}


```

**Step 3 : Change the routing file**<mark style="color:green;">**(manage-blogs.routing.ts)**</mark>

Inside the <mark style="color:green;">**src/theme/default/admin/cms/components/manage-blogs/manage-blogs.routing.ts**</mark>

Import below line

```
import * as CmsRouting from '../../../../../../../add-ons/cms/cms.routing';



```

1. Add these routes below the cmsRoutes array

&#x20;**manageBlogRoutes.push(CmsRouting.CmsBlogRoutes\[0]);**

&#x20;  **manageBlogRoutes.push(CmsRouting.CmsBlogCategoryRoutes\[0]);**

<mark style="color:green;">**src/theme/default/admin/cms/components/header/header.component.hmtl**</mark>

<mark style="color:green;">**Below line no 88**</mark>

```
 <a href="javascript:void(0)" [routerLink]="['/cms/manage-seo/category_seo']" [routerLinkActive]="'active'">
                               Category
                           </a>

<li [appHideIfUnauthorized]="'cms-blogs'" >
                           <a href="javascript:void(0)" [routerLink]="['/cms/manage-seo/blog_seo']" [routerLinkActive]="'active'">
                               Blog
                           </a>
                       </li>

```

**Step 4 : Run the application**

After you have integrated the Blogs Module into Spurtcommerce, you can use the following command to run the application.

```
 npm run large-serve

```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.

**Step 5 : Make the build**

To run the below command

```
 npm run large-build

```

Then the latest built files can be deployed into the server.

### [<mark style="color:blue;">Store Setup</mark>](#store-setup)

{% tabs %}
{% tab title="Angular" %}
These are the steps that need to be followed to do the front end store setup.

* Installing an extension&#x20;
* Update the configuration&#x20;
* Module Detail&#x20;
* Run the application&#x20;
* Make the build

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

Usually spurcommerce comes packed in a zip, whose name ends in "blogs-addOn.zip".&#x20;

Extract the zip file and copy the content of store-angular/add-ons folder into the specified path

**Path -  store-angular/add-ons**&#x20;

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.

**Update Reducer Config**

Import below line into the <mark style="color:green;">**add-ons/add-ons-reducer.ts**</mark>

```
     import * as fromBlogs from './Blogs/core/reducer/blogs.reducer';

```

**Add the reducer into the below object**

&#x20;     blogs: fromBlogs.reducer,

**After adding its looks like below**

```
   export const AddOnReducers: ActionReducerMap<State> = {
      blogs: fromBlogs.reducer
         }



```

**Update State Config**

Import below line into the <mark style="color:green;">**add-ons/add-ons-state.ts**</mark>

```
   import { BlogsState } from './Blogs/core/reducer/blogs.state';
 

```

Add the state into the below object

```
    blogs: BlogsState;

```

After adding its looks like below

```
export interface AddOnAppState {
    blogs: BlogsState;
}


```

**Step 3 : Update Default routing file(default.routing.ts)**

Inside the <mark style="color:green;">**src/default/default.routing.ts**</mark>

Import below line

```
import * as blogRouting from '../../add-ons/Blogs/blogs.routing';


```

Add the blog routes in below the routes array

```
routes.forEach(data => {
  if (data && data.children) {
    console.log('data is',data.children);
    data.children.push(blogRouting.BlogsRoutes[0]);
  }
});

```

**Step 4 : Run the application**

After you have integrated the Blogs Module into Spurtcommerce, you can use the following command to run the application.

```
 ng serve

```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.

**Step 5 : Make the build**

To run the below command

```
 ng build –prod

```

Then the latest built files can be deployed into the server.
{% endtab %}

{% tab title="Flutter" %}
These are the steps that need to be followed to do the front end store setup.

* Installing an extension&#x20;
* Update the configuration&#x20;
* Module Detail
* &#x20;Run the Application&#x20;
* Make the build

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

Extract the store-flutter folder  inside the folder go to (store-fluter → add-ons → Blogs folder) and copy the Blogs folder  and place the copied folder&#x20;

inside the project folder

**Add on location:**&#x20;

&#x20;                           <mark style="color:green;">**projectFolder->lib->add-ons**</mark>

**After placing it it will look like this**&#x20;

&#x20;                             &#x20;**&#x20;&#x20;**<mark style="color:green;">**projectFolder->lib->add-ons->Blogs**</mark>

Once you finish these steps continue to the next step

**Step 2 : Update the configuration**

After extracting the add on zip file for changing the configurations in addons.dart, you have to follow the steps below:

**Go to**&#x20;

&#x20;             <mark style="color:green;">**projectFolder->lib->add-ons->addonsshared.dart**</mark>

Then inside *addonsShared* array paste the following content

```
  {"Blog": SpurtBlog(), "data":""},
```

After placing the above files it will look like this

```
List addonsShared = [
   {"Blog": SpurtBlog(), "data":""},
];
```

Then give the following imports

```
import 'package:spurtcommerce/add-ons/Blogs/blog.dart';
```

Or&#x20;

There will be a popup for quick fix

**Step 3 : Module detail**

After executing the above mentioned steps, we have to place these below lines in the core folder to show the rating and review to the user.

**Blog**

In the <mark style="color:green;">**projectFolder->lib->core->shared->drawer.dart**</mark> file update this line

For updating the tab header

```
  findMyClass("Blog", “”),
```

Add this line to your side menu to get blogs section

**Step 4 : Run the application**

After integrating the Rating and Review Module into Spurt Commerce, you can use the following commands to run the application in terminal.

```
$ flutter run
```

Or In **Run** menu select run without debugging&#x20;

In case if throws any exception

**$ flutter run –no-sound-null-safety**

Once you execute the above command you can view the installed module in Spurt Commerce, within the page in which you have integrated

Step 5 : Make the build&#x20;

In order to build, you need to run the following commands. In order to check the application, run the following commands and build the application.

```
$flutter build
```

If you want to split the abi then

```
$flutter build –split-per-abi
```

For bundle build

```
$flutter build appbundle
```

{% endtab %}

{% tab title="React" %}
These are the steps that need to be followed to do the front end store setup.

* Installing an extension&#x20;
* Update the configuration&#x20;
* Run the application&#x20;
* Make the build

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

<br>

Usually spurcommerce comes packed in a zip, whose name ends in "blogs-addOns.zip". Extract the zip file and copy the content of store-react/addOns into the specified path as given below

**Path - addOns/Blogs**

**Add on location:**&#x20;

&#x20;                                           *projectFolder->addOns*&#x20;

**After placing it it will look like this**&#x20;

&#x20;                                  *projectFolder->addOns->Blogs*

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce addonsconfig.js files. For this, you need to follow the steps below.

Once you finish the first Step now declare the necessary plugins in the addonconfig.js file

* Import below line into the addonconfig.js

**import SpurtBlogGridplugin from './Blogs/BlogGridPlugin'**

**import SpurtBlogDetail from './Blogs/BlogDetail'**

<br>

* Add the *BlogGridplugin i*nto the below object &#x20;

```
export const AddonsComponent={
SpurtBlogGridplugin
    SpurtBlogDetail

}
```

&#x20;**Step 3 : Module Detail**

The modules pertaining to Blogs are listed below. You may use these modules, in any page of Spurtcommerce.

&#x20;                                  *Blog Component:*

**{ConnectPlugin.SpurtBlogGridplugin && \<ConnectPlugin.SpurtBlogGridplugin />}**

**SpurtBlogDetail Component:**

**{ConnectPlugin.SpurtBlogDetail && \<ConnectPlugin.SpurtBlogDetail bid={router.query.bid}/>}**

<br>

**Step 4 : Run the application**

After you have integrated the Blog Module into Spurtcommerce, you can use the following command to run the application.

```
$ npm run dev
```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.

**Step 5 : Make the build**

To run the below command

```
	$ npm run build or yarn nun build
```

Then the latest built files can be deployed into the server.
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spurtcommerce.com/addons/b2b-related-addons/blogs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
