Skip to content

Commit dd9872b

Browse files
Merge pull request #22 from contentstack/feat/ECO-809_dynamic_page_generation
feat: dynamic page generation
2 parents 1621765 + 7e88d60 commit dd9872b

16 files changed

+16761
-226
lines changed

package-lock.json

Lines changed: 16672 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
"@contentstack/live-preview-utils": "^1.0.1",
1616
"@contentstack/utils": "^1.1.1",
1717
"contentstack": "^3.15.0",
18-
"moment": "^2.29.1",
18+
"moment": "^2.29.2",
1919
"register-service-worker": "^1.7.1",
2020
"vue": "^3.2.27",
2121
"vue-json-pretty": "^1.8.2",
2222
"vue-json-tree-viewer": "^1.0.2",
2323
"vue-meta": "^2.4.0",
2424
"vue-router": "^4.0.12",
25+
"vue-skeletor": "^1.0.6",
2526
"vuex": "^4.0.2"
2627
},
2728
"devDependencies": {
@@ -68,6 +69,7 @@
6869
"not dead"
6970
],
7071
"prettier": {
71-
"singleQuote": true
72+
"singleQuote": true,
73+
"endOfLine": "auto"
7274
}
7375
}

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<Header />
4-
<router-view />
4+
<router-view :key="$route.path" />
55
<Footer />
66
</div>
77
</template>

src/components/Footer.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ export default {
6666
contentTypeUid: 'footer',
6767
jsonRtePath: ['copyright']
6868
});
69+
let responsePages = await Stack.getEntries({
70+
contentTypeUid: 'page'
71+
});
72+
let navFooterList = response[0].navigation.link;
73+
if (responsePages.length !== response.length) {
74+
responsePages.forEach(entry => {
75+
const fFound = response[0].navigation.link.find(
76+
link => link.title === entry.title
77+
);
78+
if (!fFound) {
79+
navFooterList.push({ title: entry.title, href: entry.url });
80+
}
81+
});
82+
}
6983
this.data = response[0];
7084
this.$store.dispatch('setFooter', response[0]);
7185
}

src/components/Header.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ export default {
7575
referenceFieldPath: `navigation_menu.page_reference`,
7676
jsonRtePath: ['notification_bar.announcement_text']
7777
});
78+
let responsePages = await Stack.getEntries({
79+
contentTypeUid: 'page'
80+
});
81+
let navHeaderList = response[0].navigation_menu;
82+
if (responsePages.length !== response.length) {
83+
responsePages.forEach(entry => {
84+
const hFound = response[0].navigation_menu.find(
85+
navLink => navLink.label === entry.title
86+
);
87+
88+
if (!hFound) {
89+
navHeaderList.push({
90+
label: entry.title,
91+
page_reference: [{ title: entry.title, url: entry.url }]
92+
});
93+
}
94+
});
95+
}
7896
this.data = response[0];
7997
this.$store.dispatch('setHeader', response[0]);
8098
}

src/components/HeroBanner.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@
1313
{{ data.banner_description }}
1414
</p>
1515
<template v-if="title === 'home-content'">
16-
<router-link aria-current="page" class="btn tertiary-btn" to="/">
16+
<router-link
17+
v-if="data.call_to_action.title && data.call_to_action.href"
18+
aria-current="page"
19+
class="btn tertiary-btn"
20+
to="/"
21+
>
1722
Read more
1823
</router-link>
1924
</template>
2025
</div>
21-
<img :src="data.banner_image.url" :alt="data.banner_image.title" />
26+
<img
27+
v-if="data.banner_image"
28+
:src="data.banner_image.url"
29+
:alt="data.banner_image.title"
30+
/>
2231
</div>
2332
</template>
2433

src/components/RenderComponents.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
:data="component.hero_banner"
1717
/>
1818
<HeroBanner
19-
v-if="component.hero_banner && page === 'About Us'"
19+
v-if="component.hero_banner && page !== 'Home'"
2020
:key="index"
2121
title="about-content"
2222
:data="component.hero_banner"
@@ -41,8 +41,8 @@
4141
:key="index"
4242
:data="component.section_with_buckets"
4343
/>
44-
<AboutSectionBucket
45-
v-if="component.section_with_buckets && page === 'About Us'"
44+
<SectionWithBuckets
45+
v-if="component.section_with_buckets && page !== 'Home'"
4646
:key="index"
4747
:data="component.section_with_buckets"
4848
/>
@@ -56,6 +56,11 @@
5656
:key="index"
5757
:data="component.section_with_html_code"
5858
/>
59+
<SectionWithEmbedObject
60+
v-if="component.section_with_html_code && page !== 'Contact Us'"
61+
:key="index"
62+
:data="component.section_with_html_code"
63+
/>
5964
</template>
6065
</main>
6166
</template>
@@ -67,15 +72,13 @@ import SectionWithCards from '../components/SectionWithCards';
6772
import TeamSection from '../components/TeamSection';
6873
import SectionWithEmbedObject from '../components/SectionWithEmbedObject';
6974
import SectionWithBuckets from '../components/SectionWithBuckets';
70-
import AboutSectionBucket from '../components/AboutSectionBucket';
7175
import BlogSection from '../components/BlogSection';
7276
import Devtools from '../components/Devtools.vue';
7377
export default {
7478
components: {
7579
HeroBanner,
7680
Section,
7781
SectionWithBuckets,
78-
AboutSectionBucket,
7982
SectionWithCards,
8083
TeamSection,
8184
BlogSection,

src/components/Section.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
<p>
88
{{ data.description }}
99
</p>
10-
<router-link aria-current="page" class="btn secondary-btn" to="/">
10+
<router-link
11+
v-if="data.call_to_action.title"
12+
aria-current="page"
13+
class="btn secondary-btn"
14+
to="/"
15+
>
1116
{{ data.call_to_action.title }}
1217
</router-link>
1318
</div>
@@ -18,7 +23,12 @@
1823
<p>
1924
{{ data.description }}
2025
</p>
21-
<router-link aria-current="page" class="btn secondary-btn" to="/">
26+
<router-link
27+
v-if="data.call_to_action.title"
28+
aria-current="page"
29+
class="btn secondary-btn"
30+
to="/"
31+
>
2232
{{ data.call_to_action.title }}
2333
</router-link>
2434
</div>

src/components/SectionWithBuckets.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
<img :src="index.icon.url" :alt="index.icon.title" />
1010
<h3>{{ index.title_h3 }}</h3>
1111
<p v-html="index.description" />
12-
<router-link :to="index.call_to_action.href">
12+
<router-link
13+
v-if="index.call_to_action.href"
14+
:to="index.call_to_action.href"
15+
>
1316
{{ index.call_to_action.title }}--&gt;
1417
</router-link>
1518
</div>

src/components/Tooltip.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
<span data-bs-toggle="modal" data-bs-target="#staticBackdrop"
44
><img src="/json.svg" alt="JSON Preview icon"
55
/></span>
6-
<div class="Tooltip-top" ref="toolTipRef">
7-
JSON Preview
8-
</div>
6+
<div class="Tooltip-top" ref="toolTipRef">JSON Preview</div>
97
</div>
108
</template>
119

src/router.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { createRouter, createWebHistory } from 'vue-router';
22
import Home from './views/Home.vue';
3-
import About from './views/About.vue';
4-
import Contact from './views/Contact.vue';
53
import Blog from './views/Blog.vue';
64
import BlogPost from './views/BlogPost.vue';
75
import NotFound from './views/404.vue';
@@ -12,12 +10,8 @@ const routes = [
1210
component: Home
1311
},
1412
{
15-
path: '/about-us',
16-
component: About
17-
},
18-
{
19-
path: '/contact-us',
20-
component: Contact
13+
path: '/:page',
14+
component: Home
2115
},
2216
{
2317
path: '/blog',

src/views/404.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
<div class="error-page">
44
<h1>404: Not Found</h1>
55
<p>You just hit a route that doesn&#39;t exist... the sadness.</p>
6-
<router-link to="/">
7-
Navigate to home page
8-
</router-link>
6+
<router-link to="/">Navigate to home page</router-link>
97
</div>
108
</div>
119
</template>

src/views/About.vue

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/views/Blog.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,21 @@
4646
</div>
4747
</div>
4848
</main>
49+
<Skeletor v-else height="100vh" />
4950
</template>
5051

5152
<script>
5253
import moment from 'moment';
5354
import Stack from '../plugins/contentstack';
5455
import BlogBanner from '../components/BlogBanner';
5556
import { onEntryChange } from '../plugins/contentstack';
57+
import 'vue-skeletor/dist/vue-skeletor.css';
58+
import { Skeletor } from 'vue-skeletor';
5659
5760
export default {
5861
components: {
59-
BlogBanner
62+
BlogBanner,
63+
Skeletor
6064
},
6165
data() {
6266
return {

src/views/Contact.vue

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/views/Home.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@
66
:entryUid="data.uid"
77
:locale="data.locale"
88
/>
9+
<NotFound v-else-if="data !== null" />
10+
<Skeletor v-else height="100vh" />
911
</template>
1012

1113
<script>
1214
import Stack from '../plugins/contentstack';
1315
import RenderComponent from '../components/RenderComponents';
1416
import { onEntryChange } from '../plugins/contentstack';
17+
import NotFound from './404.vue';
18+
import 'vue-skeletor/dist/vue-skeletor.css';
19+
import { Skeletor } from 'vue-skeletor';
1520
1621
export default {
1722
name: 'Home',
1823
components: {
19-
RenderComponent
24+
RenderComponent,
25+
NotFound,
26+
Skeletor
2027
},
2128
data() {
2229
return {

0 commit comments

Comments
 (0)