Skip to content

feat: dynamic page generation #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16,761 changes: 16,672 additions & 89 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
"@contentstack/live-preview-utils": "^1.0.1",
"@contentstack/utils": "^1.1.1",
"contentstack": "^3.15.0",
"moment": "^2.29.1",
"moment": "^2.29.2",
"register-service-worker": "^1.7.1",
"vue": "^3.2.27",
"vue-json-pretty": "^1.8.2",
"vue-json-tree-viewer": "^1.0.2",
"vue-meta": "^2.4.0",
"vue-router": "^4.0.12",
"vue-skeletor": "^1.0.6",
"vuex": "^4.0.2"
},
"devDependencies": {
Expand Down Expand Up @@ -68,6 +69,7 @@
"not dead"
],
"prettier": {
"singleQuote": true
"singleQuote": true,
"endOfLine": "auto"
}
}
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<Header />
<router-view />
<router-view :key="$route.path" />
<Footer />
</div>
</template>
Expand Down
14 changes: 14 additions & 0 deletions src/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ export default {
contentTypeUid: 'footer',
jsonRtePath: ['copyright']
});
let responsePages = await Stack.getEntries({
contentTypeUid: 'page'
});
let navFooterList = response[0].navigation.link;
if (responsePages.length !== response.length) {
responsePages.forEach(entry => {
const fFound = response[0].navigation.link.find(
link => link.title === entry.title
);
if (!fFound) {
navFooterList.push({ title: entry.title, href: entry.url });
}
});
}
this.data = response[0];
this.$store.dispatch('setFooter', response[0]);
}
Expand Down
18 changes: 18 additions & 0 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ export default {
referenceFieldPath: `navigation_menu.page_reference`,
jsonRtePath: ['notification_bar.announcement_text']
});
let responsePages = await Stack.getEntries({
contentTypeUid: 'page'
});
let navHeaderList = response[0].navigation_menu;
if (responsePages.length !== response.length) {
responsePages.forEach(entry => {
const hFound = response[0].navigation_menu.find(
navLink => navLink.label === entry.title
);

if (!hFound) {
navHeaderList.push({
label: entry.title,
page_reference: [{ title: entry.title, url: entry.url }]
});
}
});
}
this.data = response[0];
this.$store.dispatch('setHeader', response[0]);
}
Expand Down
13 changes: 11 additions & 2 deletions src/components/HeroBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@
{{ data.banner_description }}
</p>
<template v-if="title === 'home-content'">
<router-link aria-current="page" class="btn tertiary-btn" to="/">
<router-link
v-if="data.call_to_action.title && data.call_to_action.href"
aria-current="page"
class="btn tertiary-btn"
to="/"
>
Read more
</router-link>
</template>
</div>
<img :src="data.banner_image.url" :alt="data.banner_image.title" />
<img
v-if="data.banner_image"
:src="data.banner_image.url"
:alt="data.banner_image.title"
/>
</div>
</template>

Expand Down
13 changes: 8 additions & 5 deletions src/components/RenderComponents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:data="component.hero_banner"
/>
<HeroBanner
v-if="component.hero_banner && page === 'About Us'"
v-if="component.hero_banner && page !== 'Home'"
:key="index"
title="about-content"
:data="component.hero_banner"
Expand All @@ -41,8 +41,8 @@
:key="index"
:data="component.section_with_buckets"
/>
<AboutSectionBucket
v-if="component.section_with_buckets && page === 'About Us'"
<SectionWithBuckets
v-if="component.section_with_buckets && page !== 'Home'"
:key="index"
:data="component.section_with_buckets"
/>
Expand All @@ -56,6 +56,11 @@
:key="index"
:data="component.section_with_html_code"
/>
<SectionWithEmbedObject
v-if="component.section_with_html_code && page !== 'Contact Us'"
:key="index"
:data="component.section_with_html_code"
/>
</template>
</main>
</template>
Expand All @@ -67,15 +72,13 @@ import SectionWithCards from '../components/SectionWithCards';
import TeamSection from '../components/TeamSection';
import SectionWithEmbedObject from '../components/SectionWithEmbedObject';
import SectionWithBuckets from '../components/SectionWithBuckets';
import AboutSectionBucket from '../components/AboutSectionBucket';
import BlogSection from '../components/BlogSection';
import Devtools from '../components/Devtools.vue';
export default {
components: {
HeroBanner,
Section,
SectionWithBuckets,
AboutSectionBucket,
SectionWithCards,
TeamSection,
BlogSection,
Expand Down
14 changes: 12 additions & 2 deletions src/components/Section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
<p>
{{ data.description }}
</p>
<router-link aria-current="page" class="btn secondary-btn" to="/">
<router-link
v-if="data.call_to_action.title"
aria-current="page"
class="btn secondary-btn"
to="/"
>
{{ data.call_to_action.title }}
</router-link>
</div>
Expand All @@ -18,7 +23,12 @@
<p>
{{ data.description }}
</p>
<router-link aria-current="page" class="btn secondary-btn" to="/">
<router-link
v-if="data.call_to_action.title"
aria-current="page"
class="btn secondary-btn"
to="/"
>
{{ data.call_to_action.title }}
</router-link>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/SectionWithBuckets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<img :src="index.icon.url" :alt="index.icon.title" />
<h3>{{ index.title_h3 }}</h3>
<p v-html="index.description" />
<router-link :to="index.call_to_action.href">
<router-link
v-if="index.call_to_action.href"
:to="index.call_to_action.href"
>
{{ index.call_to_action.title }}--&gt;
</router-link>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/components/Tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
<span data-bs-toggle="modal" data-bs-target="#staticBackdrop"
><img src="/json.svg" alt="JSON Preview icon"
/></span>
<div class="Tooltip-top" ref="toolTipRef">
JSON Preview
</div>
<div class="Tooltip-top" ref="toolTipRef">JSON Preview</div>
</div>
</template>

Expand Down
10 changes: 2 additions & 8 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { createRouter, createWebHistory } from 'vue-router';
import Home from './views/Home.vue';
import About from './views/About.vue';
import Contact from './views/Contact.vue';
import Blog from './views/Blog.vue';
import BlogPost from './views/BlogPost.vue';
import NotFound from './views/404.vue';
Expand All @@ -12,12 +10,8 @@ const routes = [
component: Home
},
{
path: '/about-us',
component: About
},
{
path: '/contact-us',
component: Contact
path: '/:page',
component: Home
},
{
path: '/blog',
Expand Down
4 changes: 1 addition & 3 deletions src/views/404.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
<div class="error-page">
<h1>404: Not Found</h1>
<p>You just hit a route that doesn&#39;t exist... the sadness.</p>
<router-link to="/">
Navigate to home page
</router-link>
<router-link to="/">Navigate to home page</router-link>
</div>
</div>
</template>
Expand Down
55 changes: 0 additions & 55 deletions src/views/About.vue

This file was deleted.

6 changes: 5 additions & 1 deletion src/views/Blog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@
</div>
</div>
</main>
<Skeletor v-else height="100vh" />
</template>

<script>
import moment from 'moment';
import Stack from '../plugins/contentstack';
import BlogBanner from '../components/BlogBanner';
import { onEntryChange } from '../plugins/contentstack';
import 'vue-skeletor/dist/vue-skeletor.css';
import { Skeletor } from 'vue-skeletor';

export default {
components: {
BlogBanner
BlogBanner,
Skeletor
},
data() {
return {
Expand Down
53 changes: 0 additions & 53 deletions src/views/Contact.vue

This file was deleted.

9 changes: 8 additions & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@
:entryUid="data.uid"
:locale="data.locale"
/>
<NotFound v-else-if="data !== null" />
<Skeletor v-else height="100vh" />
</template>

<script>
import Stack from '../plugins/contentstack';
import RenderComponent from '../components/RenderComponents';
import { onEntryChange } from '../plugins/contentstack';
import NotFound from './404.vue';
import 'vue-skeletor/dist/vue-skeletor.css';
import { Skeletor } from 'vue-skeletor';

export default {
name: 'Home',
components: {
RenderComponent
RenderComponent,
NotFound,
Skeletor
},
data() {
return {
Expand Down