Runtime API Examples
This page demonstrates usage of some of the runtime APIs provided by VitePress.
The main useData() API can be used to access site, theme, and page data for the current page. It works in both .md and .vue files:
md
<script setup>
import { useData } from 'vitepress'
const { theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>Results
Theme Data
Theme Object
{
"logo": "images/alien-green.png",
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "Frontend",
"items": [
{
"items": [
{
"text": "Html",
"link": "/frontend/html"
},
{
"text": "CSS",
"link": "/frontend/css"
},
{
"text": "Javascript",
"link": "/frontend/js"
},
{
"text": "Bootstrap",
"link": "/frontend/bs"
},
{
"text": "SASS",
"link": "/frontend/sass"
},
{
"text": "Jest",
"link": "/frontend/jest"
}
]
},
{
"items": [
{
"text": "Vue.js",
"link": "/frontend/vue"
},
{
"text": "Vue Test Utils",
"link": "/frontend/vue-test-utils"
},
{
"text": "Angular",
"link": "/frontend/angular"
}
]
},
{
"items": [
{
"text": "vite",
"link": "/frontend/vite"
},
{
"text": "webpack",
"link": "/frontend/webpack"
}
]
}
]
},
{
"text": "Backend",
"items": [
{
"items": [
{
"text": "Java",
"link": "/backend/java"
},
{
"text": "Spring",
"link": "/backend/spring"
},
{
"text": "Hibernate",
"link": "/backend/hibernate"
}
]
},
{
"items": [
{
"text": "JUnit",
"link": "/backend/junit"
},
{
"text": "Cucumber",
"link": "/backend/cucumber"
}
]
},
{
"items": [
{
"text": "Object Mapper",
"link": "/backend/mapper"
},
{
"text": "JSON",
"link": "/backend/json"
},
{
"text": "XML",
"link": "/backend/xml"
},
{
"text": "Lombok",
"link": "/backend/lombok"
},
{
"text": "Logger (SLF4J)",
"link": "/backend/logger"
},
{
"text": "Feign",
"link": "/backend/feign"
}
]
}
]
},
{
"text": "APIs",
"items": [
{
"items": [
{
"text": "Http",
"link": "/api/http"
},
{
"text": "CORS",
"link": "/api/cors"
},
{
"text": "REST API",
"link": "/api/rest"
},
{
"text": "OWASP",
"link": "/api/owasp"
}
]
},
{
"items": [
{
"text": "Swagger",
"link": "/api/swagger"
},
{
"text": "OpenAPI",
"link": "/api/openapi"
}
]
},
{
"items": [
{
"text": "WebServices",
"link": "/api/webservices"
},
{
"text": "Microservices",
"link": "/api/microservices"
}
]
},
{
"items": [
{
"text": "Apache Kafka",
"link": "/api/kafka"
},
{
"text": "RabbitMQ",
"link": "/api/rabbit-mq"
}
]
}
]
},
{
"text": "Devops & CICD",
"items": [
{
"items": [
{
"text": "Git",
"link": "/devops/git"
},
{
"text": "Gradle",
"link": "/devops/gradle"
}
]
},
{
"items": [
{
"text": "Containerization",
"link": "/devops/containerization"
},
{
"text": "Docker",
"link": "/devops/docker"
}
]
},
{
"items": [
{
"text": "Jenkins",
"link": "/devops/jenkins"
},
{
"text": "Puppet",
"link": "/devops/puppet"
},
{
"text": "NGINX",
"link": "/devops/nginx"
},
{
"text": "Nomad",
"link": "/devops/nomad"
},
{
"text": "Kubernetes",
"link": "/devops/kubernetes"
}
]
},
{
"items": [
{
"text": "ELK",
"link": "/devops/elk"
},
{
"text": "Grafana",
"link": "/devops/grafana"
}
]
}
]
},
{
"text": "SWE",
"items": [
{
"items": [
{
"text": "Clean Code",
"link": "/swe/clean-code"
},
{
"text": "Design Patterns",
"link": "/swe/design-patterns"
}
]
},
{
"items": [
{
"text": "Cloud Computing",
"link": "/swe/cloud-computing"
},
{
"text": "Distributed Systems",
"link": "/swe/distributed-systems"
},
{
"text": "System Design Concepts",
"link": "/swe/system-design"
},
{
"text": "System Design Examples",
"link": "/swe/system-design-examples"
}
]
},
{
"items": [
{
"text": "AWS",
"link": "/swe/aws"
}
]
}
]
},
{
"text": "CSE",
"items": [
{
"text": "Data Structures",
"link": "/cse/ds"
},
{
"text": "Algorithms",
"link": "/cse/algo"
},
{
"text": "Operating Systems (OS)",
"link": "/cse/os"
},
{
"text": "DBMS",
"link": "/cse/dbms"
},
{
"text": "Computer Networks",
"link": "/cse/networks"
},
{
"items": [
{
"text": "Programming",
"link": "/cse/programming-basics"
},
{
"text": "Cheat Sheet",
"link": "/cse/cheatsheet"
},
{
"text": "Puzzles",
"link": "/cse/puzzles"
}
]
}
]
},
{
"text": "AI",
"items": [
{
"text": "Introduction",
"link": "/ai/intro"
}
]
},
{
"text": "Misc",
"items": [
{
"items": [
{
"text": "Jekyll",
"link": "/misc/jekyll"
},
{
"text": "Chrome",
"link": "/misc/chrome"
}
]
},
{
"text": "MD Examples",
"link": "/misc/markdown-examples"
},
{
"text": "References",
"link": "/misc/refs"
}
]
}
],
"sidebar": {
"/frontend": [
{
"text": "Overview",
"link": "/frontend"
},
{
"text": "Basic",
"items": [
{
"text": "HTML",
"link": "/frontend/html"
},
{
"text": "CSS",
"link": "/frontend/css"
},
{
"text": "Javascript",
"link": "/frontend/js"
}
]
},
{
"text": "Libs & Preprocessors",
"items": [
{
"text": "Bootstrap",
"link": "/frontend/bs"
},
{
"text": "Sass",
"link": "/frontend/sass"
},
{
"text": "Typescript",
"link": "/frontend/ts"
}
]
},
{
"text": "Frameworks",
"items": [
{
"text": "Vue3",
"link": "/frontend/vue"
},
{
"text": "Angular",
"link": "/frontend/angular"
}
]
},
{
"text": "Testing",
"items": [
{
"text": "Jest",
"link": "/frontend/jest"
},
{
"text": "Vue Test Utils",
"link": "/frontend/vue-test-utils"
},
{
"text": "Vue Test (external)",
"link": "https://test-utils.vuejs.org/guide/"
}
]
},
{
"text": "Module Bundler",
"items": [
{
"text": "Vite",
"link": "/frontend/vite"
},
{
"text": "Webpack",
"link": "/frontend/webpack"
}
]
}
],
"/backend": [
{
"text": "Overview",
"link": "/backend"
},
{
"text": "Basic",
"items": [
{
"text": "Java",
"link": "/backend/java"
},
{
"text": "Spring",
"link": "/backend/spring"
},
{
"text": "Hibernate",
"link": "/backend/hibernate"
}
]
},
{
"text": "Testing",
"items": [
{
"text": "JUnit",
"link": "/backend/junit"
},
{
"text": "Cucumber",
"link": "/backend/cucumber"
}
]
},
{
"text": "Libraries",
"items": [
{
"text": "Object Mapper",
"link": "/backend/mapper"
},
{
"text": "Json",
"link": "/backend/json"
},
{
"text": "XML",
"link": "/backend/xml"
},
{
"text": "Lombok",
"link": "/backend/lombok"
},
{
"text": "Logger SLF4J",
"link": "/backend/logger"
},
{
"text": "Feign",
"link": "/backend/feign"
}
]
}
],
"/backend/java": [
{
"text": "Java Home Examples",
"link": "/markdown-examples"
},
{
"text": "Java",
"collapsed": true,
"items": [
{
"text": "Markdown Examples",
"link": "/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "/api-examples"
},
{
"text": "Elements",
"link": "/elements"
}
]
}
],
"/backend/spring": [
{
"text": "Spring Framework",
"link": "/backend/spring"
},
{
"text": "Spring Core",
"collapsed": true,
"items": [
{
"text": "Introduction",
"link": "/backend/spring/core"
}
]
},
{
"text": "Spring Web",
"collapsed": true,
"items": [
{
"text": "Introduction",
"link": "/backend/spring/web"
}
]
},
{
"text": "Spring Data",
"collapsed": true,
"items": [
{
"text": "Introduction",
"link": "/backend/spring/data"
}
]
},
{
"text": "Spring Security",
"collapsed": true,
"items": [
{
"text": "Introduction",
"link": "/backend/spring/security"
}
]
}
],
"/api": [
{
"text": "Overview",
"link": "/api"
},
{
"text": "Core",
"items": [
{
"text": "Http",
"link": "/api/http"
},
{
"text": "CORS",
"link": "/api/cors"
},
{
"text": "REST",
"link": "/api/rest"
},
{
"text": "OWASP",
"link": "/api/owasp"
}
]
},
{
"text": "Services",
"items": [
{
"text": "WebServices",
"link": "/api/webservices"
},
{
"text": "Microservices",
"link": "/api/microservices"
}
]
},
{
"text": "API Docs",
"items": [
{
"text": "Swagger",
"link": "/api/swagger"
},
{
"text": "Open API",
"link": "/api/openapi"
}
]
},
{
"text": "Messaging",
"items": [
{
"text": "Apache Kafka",
"link": "/api/kafka"
},
{
"text": "Rabbit MQ",
"link": "/api/rabbit-mq"
}
]
}
],
"/devops": [
{
"text": "Overview",
"link": "/devops"
},
{
"items": [
{
"text": "Git",
"link": "/devops/git"
},
{
"text": "Gradle",
"link": "/devops/gradle"
}
]
},
{
"items": [
{
"text": "Jenkins",
"link": "/devops/jenkins"
},
{
"text": "Puppet",
"link": "/devops/puppet"
},
{
"text": "Nginx",
"link": "/devops/nginx"
}
]
},
{
"text": "Container Orchestration",
"items": [
{
"text": "Containerization",
"link": "/devops/containerization"
},
{
"text": "Docker",
"link": "/devops/docker"
},
{
"text": "Kubernetes",
"link": "/devops/kubernetes"
},
{
"text": "Hasicorp Nomad",
"link": "/devops/nomad"
}
]
},
{
"text": "Monitoring & Observability",
"items": [
{
"text": "ELK",
"link": "/devops/elk"
},
{
"text": "Grafana",
"link": "/devops/grafana"
}
]
}
],
"/swe": [
{
"text": "Overview",
"link": "/swe"
},
{
"text": "Best Practices",
"items": [
{
"text": "Clean Code",
"link": "/swe/clean-code"
},
{
"text": "Design Patterns",
"link": "/swe/design-patterns"
}
]
},
{
"text": "SWE Concepts",
"items": [
{
"text": "Cloud Computing",
"link": "/swe/cloud-computing"
},
{
"text": "Distributed Systems",
"link": "/swe/distributed-systems"
}
]
},
{
"text": "System Design",
"items": [
{
"text": "System Design Concepts",
"link": "/swe/system-design"
},
{
"text": "System Design Examples",
"link": "/swe/system-design-examples"
}
]
},
{
"text": "Cloud Platform",
"items": [
{
"text": "Amazon Web Services (AWS)",
"link": "/swe/aws"
}
]
}
],
"/cse": [
{
"items": [
{
"text": "Overview",
"link": "/cse"
}
]
},
{
"items": [
{
"text": "Data Structures",
"link": "/cse/ds"
},
{
"text": "Algorithms",
"link": "/cse/algo"
}
]
},
{
"items": [
{
"text": "Operating Systems (OS)",
"link": "/cse/os"
},
{
"text": "DBMS",
"link": "/cse/dbms"
},
{
"text": "Computer Networks",
"link": "/cse/networks"
}
]
},
{
"items": [
{
"text": "Programming",
"link": "/cse/programming-basics"
},
{
"text": "Cheat Sheet",
"link": "/cse/cheatsheet"
},
{
"text": "Puzzles",
"link": "/cse/puzzles"
}
]
}
],
"/ai": [
{
"text": "Overview",
"link": "/ai"
},
{
"items": [
{
"text": "Introduction",
"link": "/ai/intro"
}
]
}
],
"/misc": [
{
"text": "Overview",
"link": "/misc"
},
{
"text": "Miscellaneous",
"items": [
{
"text": "Jekyll",
"link": "/misc/jekyll"
},
{
"text": "Chrome",
"link": "/misc/chrome"
}
]
},
{
"text": "Examples",
"items": [
{
"text": "Markdown Examples",
"link": "/misc/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "/misc/api-examples"
}
]
},
{
"text": "Others",
"items": [
{
"text": "References",
"link": "/misc/refs"
},
{
"text": "Elements",
"link": "/misc/elements"
}
]
}
],
"/": [
{
"text": "Overview",
"link": "/misc"
},
{
"text": "Miscellaneous",
"items": [
{
"text": "Jekyll",
"link": "/misc/jekyll"
},
{
"text": "Chrome",
"link": "/misc/chrome"
}
]
},
{
"text": "Examples",
"items": [
{
"text": "Markdown Examples",
"link": "/misc/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "/misc/api-examples"
}
]
},
{
"text": "Others",
"items": [
{
"text": "References",
"link": "/misc/refs"
},
{
"text": "Elements",
"link": "/misc/elements"
}
]
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com"
}
],
"search": {
"provider": "local"
}
}Page Data
page Object
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "misc/api-examples.md",
"filePath": "misc/api-examples.md"
}Page Frontmatter
frontmatter Object
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.
