MCPcopy
hub / github.com/docsifyjs/docsify / compileEmbed

Method compileEmbed

src/core/render/compiler.js:140–180  ·  view source on GitHub ↗

* Pulls content from file and renders inline on the page as a embedded item. * * This allows you to embed different file types on the returned * page. * The basic format is: * ``` * [filename](_media/example.md ':include') * ``` * * @param {string} href The href to t

(href, title)

Source from the content-addressed store, hash-verified

138 * @return {type} Return value description.
139 */
140 compileEmbed(href, title) {
141 const { str, config } = getAndRemoveConfig(title);
142 let embed;
143 title = str;
144
145 if (config.include) {
146 if (!isAbsolutePath(href)) {
147 href = getPath(
148 process.env.SSR ? '' : this.contentBase,
149 getParentPath(this.router.getCurrentPath()),
150 href
151 );
152 }
153
154 let media;
155 if (config.type && (media = compileMedia[config.type])) {
156 embed = media.call(this, href, title);
157 embed.type = config.type;
158 } else {
159 let type = 'code';
160 if (/\.(md|markdown)/.test(href)) {
161 type = 'markdown';
162 } else if (/\.mmd/.test(href)) {
163 type = 'mermaid';
164 } else if (/\.html?/.test(href)) {
165 type = 'iframe';
166 } else if (/\.(mp4|ogg)/.test(href)) {
167 type = 'video';
168 } else if (/\.mp3/.test(href)) {
169 type = 'audio';
170 }
171
172 embed = compileMedia[type].call(this, href, title);
173 embed.type = type;
174 }
175
176 embed.fragment = config.fragment;
177
178 return embed;
179 }
180 }
181
182 _matchNotCompileLink(link) {
183 const links = this.config.noCompileLinks || [];

Callers 1

prerenderEmbedFunction · 0.80

Calls 3

getAndRemoveConfigFunction · 0.90
getPathFunction · 0.90
getCurrentPathMethod · 0.45

Tested by

no test coverage detected