PageSourceSearch

https://markdoc.dev/_next/static/chunks/pages/docs/partials-85507ce8063b4d48.js

js markdoc.dev collected 2026-10-03 21:25:46 UTC 2,336 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[942],{8782:function(n,e,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/docs/partials",function(){return a(5525)}])},5525:function(n,e,a){"use strict";a.r(e),a.d(e,{__N_SSG:function(){return h},default:function(){return k},markdoc:function(){return g}});var t=a(7294),r=a(1272),o=a(4211),s=a(4266),i=a(9266),c=a(8057),l=a(3695);let d={tags:(0,s.w)(i),nodes:(0,s.w)(c),functions:(0,s.w)(l),...(0,s.w)({})},u=new o.ZP.Tokenizer({allowComments:!0}).tokenize('---\ntitle: Partials\ndescription:\n---\n\n# {% $markdoc.frontmatter.title %}\n\nMarkdoc uses partials to reuse content across documents. A separate Markdoc file stores the content, and it\'s referenced from within the partial tag.\n\nHere\'s an example of including the `header.md` file as a partial.\n{% example %}\n\n```\n{% partial file="header.md" /%}\n```\n\n{% /example %}\n\n#### Registering partials\n\nYou define partials by creating a mapping from the file name to an abstract syntax tree (AST) node in your [`config` object](/docs/config). The default `partial` [tag](/docs/tags) looks at this config to include the right content.\n\n{% example %}\n\n```js\n/** @type {import(\'@markdoc/markdoc\').Config} */\nconst config = {\n  partials: {\n    \'header.md\': Markdoc.parse(`# My header`)\n  }\n};\n\nconst doc = `\n{% partial file="header.md" /%}\n`;\n\nconst ast = Markdoc.parse(doc);\n\nconst content = Markdoc.transform(ast, config);\n```\n\n{% /example %}\n\nIf you want the `partial` tag to behave differently, you can override it in `Config.tags`.\n\n#### Passing variables\n\nPartials are like any other tags, so you can pass [variables](/docs/variables) as [attributes](/docs/attributes) to them such as:\n\n{% example %}\n\n```\n{% partial file="header.md" variables={name: "My header name"} /%}\n```\n\n{% /example %}\n\nand access the variables as you would in a regular Markdoc document:\n\n{% example %}\n\n```\n{% $name %}\n```\n\n{% /example %}\n'),f=o.ZP.parse(u,{slots:!1}),m=f.attributes.frontmatter?r.ZP.load(f.attributes.frontmatter):{},{components:p}=(0,s.J)(d);var h=!0;let g={frontmatter:m};function k(n){let e=n.markdoc;return o.RZ.react(e.content,t,{components:{...p,...n.components}})}}},function(n){n.O(0,[126,649,60,963,888,774,179],function(){return n(n.s=8782)}),_N_E=n.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.