Markdown <> Web Components Formatting Issues #1267
Replies: 3 comments 1 reply
-
Well well, I guess this seems to be working after all? 😮 🤷♂️ <div class="capabilities-content item4">
<span>API Routes</span>
<i>api-routes.svg</i>
<p>Need client side data fetching or mutations? Greenwood provides API routes out of the box that are fully invested in web standards like <em>Fetch</em> and <em>FormData</em>. Of course it is all fully compatible with server-rendering Web Components; a perfect companion for HTML over the wire solutions!</p>
```js
// src/pages/api/search.js
import { renderFromHTML } from "wc-compiler";
import { getProducts } from "../lib/db.js";
export async function handler(request) {
const formData = await request.formData();
const searchTerm = formData.has("term") ? formData.get("term") : "";
const products = await getProducts(searchTerm);
const { html } = await renderFromHTML(
`
${products
.map((item, idx) => {
const { title, thumbnail } = item;
return `
<app-card
title="${idx + 1}) ${title}"
thumbnail="${thumbnail}"
></app-card>
`;
})
.join("")}
`,
[new URL("../components/card.js", import.meta.url)],
);
return new Response(html, {
headers: new Headers({
"Content-Type": "text/html",
}),
});
}
```
</div> |
Beta Was this translation helpful? Give feedback.
-
So now that it seems there is indeed no issue with indenting code fences with markdown, trying to test for Prettier automatically de-indenting said blocks, e.g. <!-- desired formatting -->
<div class="capabilities-content item1">
<span>Hybrid Routing</span>
<i>html.svg</i>
<p>Greenwood is HTML first by design. Start from just an <em>index.html</em> file or leverage <strong>hybrid, file-system based routing</strong> to easily achieve static and dynamic pages side-by-side. Single Page Applications (SPA) also supported.</p>
```shell
src/
pages/
api/
search.js # API route
index.html # Static (SSG)
products.js # Dynamic (SSR), or emit as static with pre-rendering
about.md # markdown also supported
```
</div> <!-- current formatting by Prettier -->
<div class="capabilities-content item1">
<span>Hybrid Routing</span>
<i>html.svg</i>
<p>Greenwood is HTML first by design. Start from just an <em>index.html</em> file or leverage <strong>hybrid, file-system based routing</strong> to easily achieve static and dynamic pages side-by-side. Single Page Applications (SPA) also supported.</p>
```shell
src/
pages/
api/
search.js # API route
index.html # Static (SSG)
products.js # Dynamic (SSR), or emit as static with pre-rendering
about.md # markdown also supported
```
</div> I found this Using |
Beta Was this translation helpful? Give feedback.
-
Yeah, so the main issue with <template class="capabilities-content item1">
<span>Hybrid Routing</span>
<i>html.svg</i>
<p>Greenwood is HTML first by design. Start from just an <em>index.html</em> file or leverage <strong>hybrid, file-system based routing</strong> to easily achieve static and dynamic pages side-by-side. Single Page Applications (SPA) also supported.</p>
```shell
src/
pages/
api/
search.js # API route
index.html # Static (SSG)
products.js # Dynamic (SSR), or emit as static with pre-rendering
about.md # markdown also supported
```
</template> comes out as <template class="capabilities-content item1">
<span>Hybrid Routing</span>
<i>html.svg</i>
<p>Greenwood is HTML first by design. Start from just an <em>index.html</em> file or leverage <strong>hybrid, file-system based routing</strong> to easily achieve static and dynamic pages side-by-side. Single Page Applications (SPA) also supported.</p>
<pre><code class="language-shell">src/
pages/
api/
search.js # API route
index.html # Static (SSG)
products.js # Dynamic (SSR), or emit as static with pre-rendering
about.md # markdown also supported
</code></pre>
</template> Instead of with all the <div class="capabilities-content item1">
<span>Hybrid Routing</span>
<i>html.svg</i>
<p>Greenwood is HTML first by design. Start from just an <em>index.html</em> file or leverage <strong>hybrid, file-system based routing</strong> to easily achieve static and dynamic pages side-by-side. Single Page Applications (SPA) also supported.</p>
<pre class="language-shell"><code class="language-shell">src/
pages/
api/
search.js <span class="token comment"># API route</span>
index.html <span class="token comment"># Static (SSG)</span>
products.js <span class="token comment"># Dynamic (SSR), or emit as static with pre-rendering</span>
about.md <span class="token comment"># markdown also supported</span>
</code></pre>
</div> Wonder if it's the prism highlighter package? 🤔 |
Beta Was this translation helpful? Give feedback.
-
Overview
As part of working ProjectEvergreen/www.greenwoodjs.dev#57 for the new website, noticed a few rough edges with using markdown and Web Component / Web Component adjacent HTML.
<p>
tags<template>
tag breaks parsing / highlightinghtml
fences breaks✅ Code fences have to be left aligned
Currently, it seems we can't indent code fences in markdown, like in this "card" example.
Would like it to be able to be formatted like this
Can't seem to reproduce anymore?? 🤔
✅ Prettier left aligning content automatically
❓ Line breaks introduce
<p>
tags<app-latest-post link="/blog/release/v0.30.0/" title="We just launched v0.30.0"> </app-latest-post>
Instead have to do it all on one line
❓
<template>
tag breaks parsing / highlighting - #1267 (comment)This would be nice since otherwise, we have to manually hide the
<div>
with inline CSS.I think this is just an issue with re-thinking how to manipulate the DOM since a
<template>
may not have DOM methods like a<div>
❓ HTML in JavaScript in
html
fences breaksNoticed in this feature to the website while working on a copy / paste component, that when I had custom element wrapping an HTML fenced markdown block, which itself had HTML inside it...
it broke the output renderering; missing
<p>
tag in therender
function with a line break, and ending HTML tags are missing their opening<
and confirmed with the HTML output to the clipboard
It should look like this
The resolution for now was to just make it a pure JS example
Beta Was this translation helpful? Give feedback.
All reactions