Skip to content

Commit c03f307

Browse files
committed
Removes the need for Iframes in quickstart
This registers all the components into Vue. This ia a temp fix until github.com/vuejs/vuepress/issues/1173 is patched
1 parent 66882d1 commit c03f307

File tree

2 files changed

+21
-45
lines changed

2 files changed

+21
-45
lines changed

Diff for: packages/@okta/vuepress-site/.vuepress/enhanceApp.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
var redirectsJson = require('./redirects.json');
2+
import pageComponents from '@internal/page-components'
23

3-
export default ({ router }) => {
4+
export default ({ router, Vue }) => {
45
router.addRoutes(redirectsJson)
6+
7+
for (const [name, component] of Object.entries(pageComponents)) {
8+
Vue.component(name, component)
9+
}
510
}

Diff for: packages/@okta/vuepress-theme-default/layouts/Quickstart.vue

+15-44
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
</ul>
2929
</div>
3030

31-
<div id="client_content" class="example-content-well">
32-
<div v-html="clientContent"></div>
33-
</div>
31+
<Content :pageKey="activeClientComponent" id="client_content" class="example-content-well"></Content>
3432

3533
<h2 id="server_setup">Server Setup</h2>
3634

@@ -56,9 +54,7 @@
5654
</ul>
5755
</div>
5856

59-
<div id="server_content" class="example-content-well">
60-
<div v-html="serverContent"></div>
61-
</div>
57+
<Content :pageKey="activeServerComponent" id="server_content" class="example-content-well"></Content>
6258
</div>
6359

6460
<div class="TableOfContents TableOfContentsPreload">
@@ -68,8 +64,6 @@
6864
</div>
6965
<!-- END Page Content -->
7066
</section>
71-
<iframe style="display:none;" id="clientContentIframe" :src="clientContentUrl"></iframe>
72-
<iframe style="display:none;" id="serverContentIframe" :src="serverContentUrl"></iframe>
7367
<Footer/>
7468
</div>
7569
</template>
@@ -86,13 +80,7 @@
8680
activeClient: null,
8781
activeServer: null,
8882
activeFramework: null,
89-
activeTab: null,
90-
clientContentUrl: null,
91-
serverContentUrl: null,
92-
clientContentLoading: true,
93-
serverContentLoading: true,
94-
clientContent: "",
95-
serverContent: ""
83+
activeTab: null
9684
}
9785
},
9886
created: function () {
@@ -131,17 +119,28 @@
131119
})
132120
return activeServerFrameworks.frameworks
133121
},
122+
134123
activeClientComponent: function () {
135124
let component = this.$site.pages.find((page) => {
136125
return page.regularPath.startsWith('/quickstart-fragments/'+this.activeClient+'/default-example')
137126
})
138127
128+
return component.key
129+
},
130+
131+
activeServerComponent: function () {
132+
let client = this.$themeConfig.quickstarts.clients.filter((client) => {
133+
return client.name === this.activeClient
134+
})[0];
135+
let component = this.$site.pages.find((page) => {
136+
return page.regularPath.startsWith('/quickstart-fragments/' + this.activeServer + '/' + this.activeFramework + '-' + client.serverExampleType + '/')
137+
})
138+
139139
return component.key
140140
}
141141
},
142142
watch: {
143143
activeClient: function () {
144-
this.loadClientContent()
145144
window.location.hash = '/'+this.activeClient+'/'+this.activeServer+'/'+this.activeFramework
146145
},
147146
activeServer: function () {
@@ -178,11 +177,9 @@
178177
179178
this.activeFramework = frameworkToSet
180179
181-
this.loadServerContent()
182180
window.location.hash = '/'+this.activeClient+'/'+this.activeServer+'/'+this.activeFramework
183181
},
184182
activeFramework: function () {
185-
this.loadServerContent()
186183
window.location.hash = '/'+this.activeClient+'/'+this.activeServer+'/'+this.activeFramework
187184
}
188185
},
@@ -201,32 +198,6 @@
201198
},
202199
scrollTo: function (element) {
203200
window.scrollTo(0, document.querySelectorAll(element)[0].offsetTop - 150)
204-
},
205-
206-
loadClientContent: function () {
207-
this.clientContentLoading = true
208-
209-
this.clientContentUrl = '/quickstart-fragments/' + this.activeClient + '/default-example/'
210-
211-
212-
document.getElementById('clientContentIframe').onload = () => {
213-
this.clientContentLoading = false
214-
this.clientContent = document.getElementById('clientContentIframe').contentDocument.querySelector('.PageContent-main').innerHTML
215-
}
216-
},
217-
218-
loadServerContent: function () {
219-
this.serverContentLoading = true
220-
let client = this.$themeConfig.quickstarts.clients.filter((client) => {
221-
return client.name === this.activeClient
222-
})[0];
223-
224-
this.serverContentUrl = '/quickstart-fragments/' + this.activeServer + '/' + this.activeFramework + '-' + client.serverExampleType + '/'
225-
226-
document.getElementById('serverContentIframe').onload = () => {
227-
this.serverContentLoading = false
228-
this.serverContent = document.getElementById('serverContentIframe').contentDocument.querySelector('.PageContent-main').innerHTML
229-
}
230201
}
231202
}
232203
}

0 commit comments

Comments
 (0)