1
0
Fork 0

Use vite-ssg

This commit is contained in:
Moritz Ruth 2021-12-18 19:15:49 +01:00
parent 90354a246d
commit 70ab1ed864
No known key found for this signature in database
GPG key ID: AFD57E23E753841B
6 changed files with 597 additions and 63 deletions

View file

@ -3,7 +3,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite --host", "dev": "vite --host",
"build": "vite build", "build": "vite-ssg build",
"start": "vite preview", "start": "vite preview",
"lint": "eslint . --fix" "lint": "eslint . --fix"
}, },
@ -27,6 +27,7 @@
"blobs": "^2.2.1-beta.1", "blobs": "^2.2.1-beta.1",
"ohmyfetch": "^0.4.11", "ohmyfetch": "^0.4.11",
"unplugin-icons": "^0.12.23", "unplugin-icons": "^0.12.23",
"vite-ssg": "^0.17.1",
"vue": "^3.2.26", "vue": "^3.2.26",
"vue-router": "^4.0.12" "vue-router": "^4.0.12"
} }

589
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@
</div> </div>
<div class="bg-background fixed top-0 left-0 right-0 bottom-0 z-100 backdrop-filter" :style="loadingOverlayStyle"> <div class="bg-background fixed top-0 left-0 right-0 bottom-0 z-100 backdrop-filter" :style="loadingOverlayStyle">
<div class="font-bold text-light-900 text-2xl h-full w-full flex justify-center items-center overflow-hidden" :style="loadingOverlayContentStyle"> <div class="font-bold text-light-900 text-2xl h-full w-full flex justify-center items-center overflow-hidden" :style="loadingOverlayContentStyle">
<div :class="$style.loadingText"> <div :class="$style.centerLoadingText">
Loading... Loading...
</div> </div>
<div <div
@ -34,6 +34,19 @@
font-size: 17px; font-size: 17px;
} }
.centerLoadingText {
animation: fade-in 2s ease-out both;
}
@keyframes fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.loadingText { .loadingText {
animation: fade-in-out 8s ease both; animation: fade-in-out 8s ease both;
} }
@ -50,7 +63,7 @@
<script lang="ts"> <script lang="ts">
import { computed, ref } from "vue" import { computed, ref } from "vue"
import { useWindowSize, whenever } from "@vueuse/core" import { useIntervalFn, useWindowSize, whenever } from "@vueuse/core"
import { pageComponentLoading } from "./store" import { pageComponentLoading } from "./store"
import { useRouter } from "vue-router" import { useRouter } from "vue-router"
@ -98,7 +111,7 @@
const { width, height } = useWindowSize() const { width, height } = useWindowSize()
setInterval(() => { useIntervalFn(() => {
const start = loadingStartedTime.value const start = loadingStartedTime.value
if (start === null) return if (start === null) return
if (Date.now() - start > 3000) { if (Date.now() - start > 3000) {

View file

@ -3,7 +3,9 @@
</template> </template>
<script> <script>
import { canvasPath as createBlobAnimation } from "blobs/v2/animate/index.module.js" import blobsAnimate from "blobs/v2/animate/index.js"
const { canvasPath: createBlobAnimation } = blobsAnimate
import { ref, watchEffect } from "vue" import { ref, watchEffect } from "vue"
import { useRafFn } from "@vueuse/core" import { useRafFn } from "@vueuse/core"

View file

@ -1,10 +1,10 @@
import "virtual:windi.css" import "virtual:windi.css"
import originalRoutes from "~pages" import originalRoutes from "~pages"
import { createApp, FunctionalComponent } from "vue" import { FunctionalComponent } from "vue"
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router" import { RouteRecordRaw } from "vue-router"
import App from "./App.vue" import App from "./App.vue"
import { createHead } from "@vueuse/head"
import { pageComponentLoading } from "./store" import { pageComponentLoading } from "./store"
import { ViteSSG } from "vite-ssg"
const routes = originalRoutes.map(route => { const routes = originalRoutes.map(route => {
if (typeof route.component !== "function") return route if (typeof route.component !== "function") return route
@ -23,19 +23,18 @@ const routes = originalRoutes.map(route => {
} }
}) as RouteRecordRaw[] }) as RouteRecordRaw[]
const router = createRouter({ // noinspection JSUnusedGlobalSymbols
history: createWebHistory(), export const createApp = ViteSSG(
routes, App,
scrollBehavior(to, from, savedPosition) { {
if (savedPosition) return savedPosition routes,
if (to.hash) return { el: to.hash } scrollBehavior(to, from, savedPosition) {
return { top: 0 } if (savedPosition) return savedPosition
if (to.hash) return { el: to.hash }
return { top: 0 }
}
},
() => {
} }
}) )
const head = createHead()
createApp(App)
.use(router)
.use(head)
.mount("#app")

View file

@ -12,5 +12,13 @@ export default defineConfig({
}), }),
windicssPlugin(), windicssPlugin(),
iconsPlugin() iconsPlugin()
] ],
ssgOptions: {
formatting: "minify",
includedRoutes(routes) {
return routes.filter(route => {
return /* Dynamic routes: */ !route.includes(":") && /* Blog post overview: */route !== "/blog"
})
}
}
}) })