news-analyze/public/docs/assets/api-examples.md.B5cbNgMl.js
2025-05-20 16:31:07 +08:00

121 lines
5.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {
u as p,
c as h,
o,
ae as d,
j as a,
t,
k as i,
a as s,
} from "./chunks/framework.WowTybjF.js";
const f = JSON.parse(
'{"title":"Runtime API Examples","description":"","frontmatter":{"outline":"deep"},"headers":[],"relativePath":"api-examples.md","filePath":"api-examples.md"}',
),
m = { name: "api-examples.md" },
E = Object.assign(m, {
setup(k) {
const { site: g, theme: n, page: l, frontmatter: r } = p();
return (c, e) => (
o(),
h("div", null, [
e[0] ||
(e[0] = d(
`<h1 id="runtime-api-examples" tabindex="-1">Runtime API Examples <a class="header-anchor" href="#runtime-api-examples" aria-label="Permalink to &quot;Runtime API Examples&quot;"></a></h1><p>This page demonstrates usage of some of the runtime APIs provided by VitePress.</p><p>The main <code>useData()</code> API can be used to access site, theme, and page data for the current page. It works in both <code>.md</code> and <code>.vue</code> files:</p><div class="language-md vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;script setup&gt;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">import { useData } from &#39;vitepress&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">const { theme, page, frontmatter } = useData()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;/script&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-light-font-weight:bold;--shiki-dark:#79B8FF;--shiki-dark-font-weight:bold;">## Results</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-light-font-weight:bold;--shiki-dark:#79B8FF;--shiki-dark-font-weight:bold;">### Theme Data</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;pre&gt;{{ theme }}&lt;/pre&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-light-font-weight:bold;--shiki-dark:#79B8FF;--shiki-dark-font-weight:bold;">### Page Data</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;pre&gt;{{ page }}&lt;/pre&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-light-font-weight:bold;--shiki-dark:#79B8FF;--shiki-dark-font-weight:bold;">### Page Frontmatter</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;pre&gt;{{ frontmatter }}&lt;/pre&gt;</span></span></code></pre></div><h2 id="results" tabindex="-1">Results <a class="header-anchor" href="#results" aria-label="Permalink to &quot;Results&quot;"></a></h2><h3 id="theme-data" tabindex="-1">Theme Data <a class="header-anchor" href="#theme-data" aria-label="Permalink to &quot;Theme Data&quot;"></a></h3>`,
6,
)),
a("pre", null, t(i(n)), 1),
e[1] ||
(e[1] = a(
"h3",
{ id: "page-data", tabindex: "-1" },
[
s("Page Data "),
a(
"a",
{
class: "header-anchor",
href: "#page-data",
"aria-label": 'Permalink to "Page Data"',
},
"",
),
],
-1,
)),
a("pre", null, t(i(l)), 1),
e[2] ||
(e[2] = a(
"h3",
{ id: "page-frontmatter", tabindex: "-1" },
[
s("Page Frontmatter "),
a(
"a",
{
class: "header-anchor",
href: "#page-frontmatter",
"aria-label": 'Permalink to "Page Frontmatter"',
},
"",
),
],
-1,
)),
a("pre", null, t(i(r)), 1),
e[3] ||
(e[3] = a(
"h2",
{ id: "more", tabindex: "-1" },
[
s("More "),
a(
"a",
{
class: "header-anchor",
href: "#more",
"aria-label": 'Permalink to "More"',
},
"",
),
],
-1,
)),
e[4] ||
(e[4] = a(
"p",
null,
[
s("Check out the documentation for the "),
a(
"a",
{
href: "https://vitepress.dev/reference/runtime-api#usedata",
target: "_blank",
rel: "noreferrer",
},
"full list of runtime APIs",
),
s("."),
],
-1,
)),
])
);
},
});
export { f as __pageData, E as default };