style: adjust few code styles

pull/137/head
Kia King Ishii 5 years ago
parent ac43f05188
commit 360bd35c60

@ -2,11 +2,11 @@
<div class="theme"> <div class="theme">
<h1>404</h1> <h1>404</h1>
<blockquote>{{ getMsg() }}</blockquote> <blockquote>{{ getMsg() }}</blockquote>
<a :href="$site.base" aria-label="go to home"> Take me home. </a> <a :href="$site.base" aria-label="go to home">Take me home.</a>
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
const msgs = [ const msgs = [
`There's nothing here.`, `There's nothing here.`,
`How did we get here?`, `How did we get here?`,
@ -14,7 +14,7 @@ const msgs = [
`Looks like we've got some broken links.` `Looks like we've got some broken links.`
] ]
function getMsg() { const getMsg = () => {
return msgs[Math.floor(Math.random() * msgs.length)] return msgs[Math.floor(Math.random() * msgs.length)]
} }
</script> </script>

@ -20,6 +20,10 @@ import { withBase, isExternal } from '../utils'
import type { DefaultTheme } from '../config' import type { DefaultTheme } from '../config'
import OutboundLink from './icons/OutboundLink.vue' import OutboundLink from './icons/OutboundLink.vue'
const { item } = defineProps<{
item: DefaultTheme.NavItemWithLink
}>()
const normalizePath = (path: string): string => { const normalizePath = (path: string): string => {
path = path path = path
.replace(/#.*$/, '') .replace(/#.*$/, '')
@ -31,10 +35,6 @@ const normalizePath = (path: string): string => {
return path return path
} }
const { item } = defineProps<{
item: DefaultTheme.NavItemWithLink
}>()
const route = useRoute() const route = useRoute()
const classes = computed(() => ({ const classes = computed(() => ({

@ -18,8 +18,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useNextAndPrevLinks } from '../composables/nextAndPrevLinks'
import { withBase } from '../utils' import { withBase } from '../utils'
import { useNextAndPrevLinks } from '../composables/nextAndPrevLinks'
import ArrowLeft from './icons/ArrowLeft.vue' import ArrowLeft from './icons/ArrowLeft.vue'
import ArrowRight from './icons/ArrowRight.vue' import ArrowRight from './icons/ArrowRight.vue'

@ -16,6 +16,7 @@ export type BuildOptions = Pick<
export async function build(buildOptions: BuildOptions = {}) { export async function build(buildOptions: BuildOptions = {}) {
const start = Date.now() const start = Date.now()
process.env.NODE_ENV = 'production' process.env.NODE_ENV = 'production'
const siteConfig = await resolveConfig(buildOptions.root) const siteConfig = await resolveConfig(buildOptions.root)
@ -67,5 +68,6 @@ export async function build(buildOptions: BuildOptions = {}) {
} finally { } finally {
await fs.remove(siteConfig.tempDir) await fs.remove(siteConfig.tempDir)
} }
console.log(`build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.`) console.log(`build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.`)
} }

@ -88,6 +88,7 @@ export async function bundle(
if (!isClientBuild) { if (!isClientBuild) {
return return
} }
// for each .md entry chunk, adjust its name to its correct path. // for each .md entry chunk, adjust its name to its correct path.
for (const name in bundle) { for (const name in bundle) {
const chunk = bundle[name] const chunk = bundle[name]

@ -71,9 +71,11 @@ function injectPageData(tags: string[], data: PageData) {
const code = `\nexport const __pageData = ${JSON.stringify( const code = `\nexport const __pageData = ${JSON.stringify(
JSON.stringify(data) JSON.stringify(data)
)}` )}`
const existingScriptIndex = tags.findIndex(
(tag) => scriptRE.test(tag) && !scriptSetupRE.test(tag) const existingScriptIndex = tags.findIndex((tag) => {
) return scriptRE.test(tag) && !scriptSetupRE.test(tag)
})
if (existingScriptIndex > -1) { if (existingScriptIndex > -1) {
const tagSrc = tags[existingScriptIndex] const tagSrc = tags[existingScriptIndex]
// user has <script> tag inside markdown // user has <script> tag inside markdown

Loading…
Cancel
Save