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
{ "nav": [ { "text": "Home", "link": "/" }, { "text": "API Reference", "link": "/api/" }, { "text": "Examples", "link": "https://camptocamp.github.io/geospatial-sdk/" } ], "sidebar": [ { "text": "API Reference", "items": [ { "text": "core", "collapsed": true, "items": [ { "text": "lib", "link": "/api/core/lib/", "collapsed": true, "items": [ { "text": "Classes", "collapsed": true, "items": [ { "text": "SourceLoadErrorEvent", "link": "/api/core/lib/classes/SourceLoadErrorEvent.md" } ] }, { "text": "Interfaces", "collapsed": true, "items": [ { "text": "FeaturesClickEvent", "link": "/api/core/lib/interfaces/FeaturesClickEvent.md" }, { "text": "FeaturesHoverEvent", "link": "/api/core/lib/interfaces/FeaturesHoverEvent.md" }, { "text": "MapClickEvent", "link": "/api/core/lib/interfaces/MapClickEvent.md" }, { "text": "MapContext", "link": "/api/core/lib/interfaces/MapContext.md" }, { "text": "MapContextBaseLayer", "link": "/api/core/lib/interfaces/MapContextBaseLayer.md" }, { "text": "MapContextDiff", "link": "/api/core/lib/interfaces/MapContextDiff.md" }, { "text": "MapContextLayer", "link": "/api/core/lib/interfaces/MapContextLayer.md" }, { "text": "MapContextLayerGeojson", "link": "/api/core/lib/interfaces/MapContextLayerGeojson.md" }, { "text": "MapContextLayerMapLibreStyle", "link": "/api/core/lib/interfaces/MapContextLayerMapLibreStyle.md" }, { "text": "MapContextLayerOgcApi", "link": "/api/core/lib/interfaces/MapContextLayerOgcApi.md" }, { "text": "MapContextLayerPositioned", "link": "/api/core/lib/interfaces/MapContextLayerPositioned.md" }, { "text": "MapContextLayerReordered", "link": "/api/core/lib/interfaces/MapContextLayerReordered.md" }, { "text": "MapContextLayerWfs", "link": "/api/core/lib/interfaces/MapContextLayerWfs.md" }, { "text": "MapContextLayerWms", "link": "/api/core/lib/interfaces/MapContextLayerWms.md" }, { "text": "MapContextLayerWmts", "link": "/api/core/lib/interfaces/MapContextLayerWmts.md" }, { "text": "MapContextLayerXyz", "link": "/api/core/lib/interfaces/MapContextLayerXyz.md" }, { "text": "MapEventsByType", "link": "/api/core/lib/interfaces/MapEventsByType.md" }, { "text": "ViewByExtent", "link": "/api/core/lib/interfaces/ViewByExtent.md" }, { "text": "ViewByGeometry", "link": "/api/core/lib/interfaces/ViewByGeometry.md" }, { "text": "ViewByZoomAndCenter", "link": "/api/core/lib/interfaces/ViewByZoomAndCenter.md" } ] }, { "text": "Type Aliases", "collapsed": true, "items": [ { "text": "Coordinate", "link": "/api/core/lib/type-aliases/Coordinate.md" }, { "text": "Extent", "link": "/api/core/lib/type-aliases/Extent.md" }, { "text": "LayerDimensions", "link": "/api/core/lib/type-aliases/LayerDimensions.md" }, { "text": "LayerExtras", "link": "/api/core/lib/type-aliases/LayerExtras.md" }, { "text": "MapContextView", "link": "/api/core/lib/type-aliases/MapContextView.md" } ] }, { "text": "Variables", "collapsed": true, "items": [ { "text": "FeaturesClickEventType", "link": "/api/core/lib/variables/FeaturesClickEventType.md" }, { "text": "FeaturesHoverEventType", "link": "/api/core/lib/variables/FeaturesHoverEventType.md" }, { "text": "MapClickEventType", "link": "/api/core/lib/variables/MapClickEventType.md" }, { "text": "SourceLoadErrorType", "link": "/api/core/lib/variables/SourceLoadErrorType.md" } ] }, { "text": "Functions", "collapsed": true, "items": [ { "text": "addLayerToContext", "link": "/api/core/lib/functions/addLayerToContext.md" }, { "text": "changeLayerPositionInContext", "link": "/api/core/lib/functions/changeLayerPositionInContext.md" }, { "text": "computeMapContextDiff", "link": "/api/core/lib/functions/computeMapContextDiff.md" }, { "text": "createViewFromLayer", "link": "/api/core/lib/functions/createViewFromLayer.md" }, { "text": "deepFreeze", "link": "/api/core/lib/functions/deepFreeze.md" }, { "text": "getLayerPosition", "link": "/api/core/lib/functions/getLayerPosition.md" }, { "text": "removeLayerFromContext", "link": "/api/core/lib/functions/removeLayerFromContext.md" }, { "text": "removeSearchParams", "link": "/api/core/lib/functions/removeSearchParams.md" }, { "text": "replaceLayerInContext", "link": "/api/core/lib/functions/replaceLayerInContext.md" } ] } ] } ] }, { "text": "elements", "collapsed": true, "items": [ { "text": "lib", "link": "/api/elements/lib/", "collapsed": true, "items": [ { "text": "Classes", "collapsed": true, "items": [ { "text": "SdkMapElement", "link": "/api/elements/lib/classes/SdkMapElement.md" } ] } ] } ] }, { "text": "geocoding", "collapsed": true, "items": [ { "text": "lib", "link": "/api/geocoding/lib/", "collapsed": true, "items": [ { "text": "Interfaces", "collapsed": true, "items": [ { "text": "DataGouvFrOptions", "link": "/api/geocoding/lib/interfaces/DataGouvFrOptions.md" }, { "text": "DataGouvFrResponse", "link": "/api/geocoding/lib/interfaces/DataGouvFrResponse.md" }, { "text": "GeoadminOptions", "link": "/api/geocoding/lib/interfaces/GeoadminOptions.md" }, { "text": "GeocodingResult", "link": "/api/geocoding/lib/interfaces/GeocodingResult.md" }, { "text": "GeonamesOptions", "link": "/api/geocoding/lib/interfaces/GeonamesOptions.md" } ] }, { "text": "Type Aliases", "collapsed": true, "items": [ { "text": "GeoadminResponse", "link": "/api/geocoding/lib/type-aliases/GeoadminResponse.md" } ] }, { "text": "Functions", "collapsed": true, "items": [ { "text": "queryDataGouvFr", "link": "/api/geocoding/lib/functions/queryDataGouvFr.md" }, { "text": "queryGeoadmin", "link": "/api/geocoding/lib/functions/queryGeoadmin.md" }, { "text": "queryGeonames", "link": "/api/geocoding/lib/functions/queryGeonames.md" } ] } ] } ] }, { "text": "legend", "collapsed": true, "items": [ { "text": "lib", "link": "/api/legend/lib/", "collapsed": true, "items": [ { "text": "Functions", "collapsed": true, "items": [ { "text": "createLegendFromLayer", "link": "/api/legend/lib/functions/createLegendFromLayer.md" } ] } ] } ] }, { "text": "openlayers", "collapsed": true, "items": [ { "text": "lib", "link": "/api/openlayers/lib/", "collapsed": true, "items": [ { "text": "Interfaces", "collapsed": true, "items": [ { "text": "CreateStyleOptions", "link": "/api/openlayers/lib/interfaces/CreateStyleOptions.md" }, { "text": "StyleByGeometryType", "link": "/api/openlayers/lib/interfaces/StyleByGeometryType.md" } ] }, { "text": "Functions", "collapsed": true, "items": [ { "text": "applyContextDiffToMap", "link": "/api/openlayers/lib/functions/applyContextDiffToMap.md" }, { "text": "createGeometryStyles", "link": "/api/openlayers/lib/functions/createGeometryStyles.md" }, { "text": "createMapFromContext", "link": "/api/openlayers/lib/functions/createMapFromContext.md" }, { "text": "createStyleFunction", "link": "/api/openlayers/lib/functions/createStyleFunction.md" }, { "text": "defaultHighlightStyle", "link": "/api/openlayers/lib/functions/defaultHighlightStyle.md" }, { "text": "defaultStyle", "link": "/api/openlayers/lib/functions/defaultStyle.md" }, { "text": "listen", "link": "/api/openlayers/lib/functions/listen.md" }, { "text": "resetMapFromContext", "link": "/api/openlayers/lib/functions/resetMapFromContext.md" } ] } ] } ] } ] } ], "socialLinks": [ { "icon": "github", "link": "https://github.com/vuejs/vitepress" } ] }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "api-examples.md", "filePath": "api-examples.md" }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.