Skip to content
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

WIP: SSR #78

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
18 changes: 10 additions & 8 deletions components/CurrentResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@

<script>
import { computed, onMounted, ref } from '@vue/composition-api'
import { init, use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import {
GridComponent,
TooltipComponent,
VisualMapComponent,
} from 'echarts/components'
import { BarChart, HeatmapChart } from 'echarts/charts'

import BaseSubtitle from '~/components/BaseSubtitle.vue'

Expand Down Expand Up @@ -87,6 +79,16 @@ export default {
onMounted(async function () {
await fetchStatsTotal()

const { init, use } = require('echarts/core')
const { CanvasRenderer } = require('echarts/renderers')

const {
GridComponent,
TooltipComponent,
VisualMapComponent,
} = require('echarts/components')
const { BarChart, HeatmapChart } = require('echarts/charts')

use([
GridComponent,
TooltipComponent,
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const metaTwitter = [

export default {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
ssr: false,
ssr: true,

generate: {
routes() {
Expand Down
17 changes: 11 additions & 6 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@

<ReportTutorial id="report" />

<CurrentResults
id="current-results"
:totalReportRecords="totalReportRecords"
/>
<client-only>
<CurrentResults
id="current-results"
:totalReportRecords="totalReportRecords"
/>
</client-only>

<AskedQuestions id="faq" />

Expand All @@ -50,7 +52,6 @@ import FactoryDisplay from '~/components/FactoryDisplay.vue'
import DataDisplay from '~/components/DataDisplay.vue'
import BannerJoinUs from '~/components/BannerJoinUs.vue'
import ReportTutorial from '~/components/ReportTutorial.vue'
import CurrentResults from '~/components/CurrentResults.vue'
import AskedQuestions from '~/components/AskedQuestions.vue'
import MediaReport from '~/components/MediaReport.vue'
import TheFooter from '~/components/TheFooter.vue'
Expand All @@ -67,7 +68,11 @@ export default {
DataDisplay,
BannerJoinUs,
ReportTutorial,
CurrentResults,
CurrentResults: () => {
if (!process.server && process.client) {
return import('../components/CurrentResults.vue')
}
},
AskedQuestions,
MediaReport,
TheFooter,
Expand Down