Skip to content

Instantly share code, notes, and snippets.

@brillout
Last active January 20, 2024 11:31
Show Gist options
  • Save brillout/e7fe603bd44c9ec1be7e98f3ae28636a to your computer and use it in GitHub Desktop.
Save brillout/e7fe603bd44c9ec1be7e98f3ae28636a to your computer and use it in GitHub Desktop.
// /pages/+title.js
// Environment: server, client
// This title function applies to all our pages /pages/**/+page.js
export { title }
import { useData } from 'vike/react' // or 'vike-vue' / 'vike-solid'
// If a page fetches data and data.title is defined, then use it to set the page's title (i.e the value of <title>).
function title() {
const data = useData()
return data?.title || 'SpaceX'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment