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

Docs/ssr guide #1825

Merged
merged 4 commits into from Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/docs/src/components/sidebar/navigationRoutes.ts
Expand Up @@ -55,6 +55,10 @@ export const navigationRoutes: NavigationRoute[] = [
badge: 'new',
},
},
{
name: 'ssr-guide',
displayName: 'menu.ssrGuide',
},
// GENERATOR_ADD - gettingStarted
],
},
Expand Down
29 changes: 26 additions & 3 deletions packages/docs/src/locales/en/en.json
Expand Up @@ -1026,7 +1026,6 @@
"parse": "Function that transforms input field text to date, date array or date period",
"parseDate": "Function that transforms input field text to date",
"parseValue": "Function that transforms string value to date, date array or date period"

},
"events": {
"clear": "Emitted if select value has been cleared",
Expand Down Expand Up @@ -1356,7 +1355,8 @@
"carousel": "Carousel",
"treeShaking": "Tree Shaking",
"counter": "Counter",
"nuxt": "Nuxt"
"nuxt": "Nuxt",
"ssrGuide": "SSR"
},
"all": {
"examples": "Examples",
Expand Down Expand Up @@ -3977,5 +3977,28 @@
"nuxtConfig": "Then you need to update nuxt-config.ts file:",
"moreAboutConfig": "More about configuration"
}
},
"ssrGuide": {
"title": "SSR",
"description": "Vuestic is fully compatible with server-side rendering.",
"cssVariables": {
"title": "CSS variables",
"description": "Vuestic UI uses `CSS variables` in components. For SSR you need to define them in html head element. You can use following code to generate CSS Variables based on your [ColorConfig](/services/colors-config):"
},
"solutions": {
"title": "Examples",
"description": "Here are two examples how you can add CSS variables to html head",

"nuxt": "Look at Nuxt3 guide",

"viteSsrPlugin": {
"title": "Vite SSR Plugin",
"description": "Learn more about [Vite SSR Plugin](https://vite-plugin-ssr.com/vue-tour)"
},
"vitesse": {
"title": "Vitesse",
"description": "Learn more about [Vitesse](https://github.com/antfu/vitesse) and [useHead](https://github.com/vueuse/head#server-side-rendering)"
}
}
}
}
}
8 changes: 6 additions & 2 deletions packages/docs/src/locales/ru/ru.json
Expand Up @@ -1277,7 +1277,8 @@
"carousel": "Carousel",
"treeShaking": "Tree Shaking",
"counter": "Counter",
"nuxt": "Nuxt"
"nuxt": "Nuxt",
"ssrGuide": "Ssr Guide"
},
"all": {
"examples": "Примеры",
Expand Down Expand Up @@ -3837,5 +3838,8 @@
"nuxtConfig": "Затем обновите файл nuxt-config.ts:",
"moreAboutConfig": "Подробнее про конфигурирование"
}
},
"ssrGuide": {
"title": "-- Here is the title --"
}
}
}
@@ -0,0 +1,3 @@
export default `
app.config.globalProperties.$vaColorConfig.renderCSSVarialbes()
`
@@ -0,0 +1,3 @@
export { default as cssVariables } from './css-variables'
export { default as viteSsrPlugin } from './vite-ssr-plugin'
export { default as vitesse } from './vitesse'
@@ -0,0 +1,22 @@
export default `// ...
import { createVuestic } from 'vuestic-ui'
import 'vuestic-ui/css'

export async function render(pageContext) {
// ...
app.use(createVuestic())

const appHtml = await renderToString(app)
const cssVarialbes = app.config.globalProperties.$vaColorConfig.renderCSSVarialbes()

return escapeInject\`<!DOCTYPE html>
<html>
<head>
<title>Vuestic App</title>
<style>\${cssVarialbes}</style>
</head>
<body>
<div id="app">\${dangerouslySkipEscape(appHtml)}</div>
</body>
</html>\`
}`
@@ -0,0 +1,24 @@
export default `// ...
import { createVuestic } from 'vuestic-ui'
import { ref } from 'vue'
import 'vuestic-ui/css'

const routes = setupLayouts(generatedRoutes)

export const createApp = ViteSSG(
App,
{ routes, base: import.meta.env.BASE_URL },
(ctx) => {
Object.values(import.meta.globEager('./modules/*.ts')).forEach(i => i.install?.(ctx))
ctx.app.use(createVuestic())

const head = app.config.globalProperties.$head
const colorConfig = app.config.globalProperties.$vaColorConfig
head.addHeadObjs(ref({
htmlAttrs: {
style: colorConfig.renderCSSVarialbes(),
},
}))
},
)
`
@@ -0,0 +1,28 @@
import { ApiDocsBlock } from '@/types/configTypes'
import { PageGenerationHelper } from '@/helpers/DocsHelper'
import * as code from './code-examples'

const block = new PageGenerationHelper(__dirname)

const config: ApiDocsBlock[] = [
block.title('ssrGuide.title'),
block.paragraph('ssrGuide.description'),

block.subtitle('ssrGuide.cssVariables.title'),
block.paragraph('ssrGuide.cssVariables.description'),
block.code(code.cssVariables),

block.subtitle('ssrGuide.solutions.title'),
block.paragraph('ssrGuide.solutions.description'),

block.link('ssrGuide.solutions.nuxt', '/en/getting-started/nuxt'),

block.headline('ssrGuide.solutions.viteSsrPlugin.title'),
block.paragraph('ssrGuide.solutions.viteSsrPlugin.description'),
block.code(code.viteSsrPlugin),
block.headline('ssrGuide.solutions.vitesse.title'),
block.paragraph('ssrGuide.solutions.vitesse.description'),
block.code(code.vitesse),
]

export default config
20 changes: 20 additions & 0 deletions packages/docs/src/pages/getting-started/ssr-guide.vue
@@ -0,0 +1,20 @@
<template>
<docs-content :config="configComputed" />
</template>

<script lang="ts">
import { Vue, Options } from 'vue-class-component'
import DocsContent from '../../components/DocsContent.vue'
import ssrGuideConfig from '../../page-configs/getting-started/ssr-guide/page-config'

@Options({
components: {
DocsContent,
},
})
export default class SsrGuide extends Vue {
get configComputed () {
return ssrGuideConfig
}
}
</script>