@astrojs/lit
Advanced tools
Comparing version 0.2.0 to 0.3.0
# @astrojs/lit | ||
## 0.3.0 | ||
### Minor Changes | ||
- [#3652](https://github.com/withastro/astro/pull/3652) [`7373d61c`](https://github.com/withastro/astro/commit/7373d61cdcaedd64bf5fd60521b157cfa4343558) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Adds support for passing named slots from `.astro` => Lit components. | ||
All slots are treated as Light DOM content. | ||
## 0.2.0 | ||
@@ -4,0 +12,0 @@ |
{ | ||
"name": "@astrojs/lit", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Use Lit components within Astro", | ||
@@ -32,3 +32,3 @@ "type": "module", | ||
"devDependencies": { | ||
"astro": "1.0.0-beta.48", | ||
"astro": "1.0.0-beta.54", | ||
"astro-scripts": "0.0.4", | ||
@@ -35,0 +35,0 @@ "cheerio": "^1.0.0-rc.11", |
@@ -29,3 +29,3 @@ import './server-shim.js'; | ||
function* render(Component, attrs, children) { | ||
function* render(Component, attrs, slots) { | ||
let tagName = Component; | ||
@@ -61,11 +61,19 @@ if (typeof tagName !== 'string') { | ||
} | ||
yield children || ''; // don’t print “undefined” as string | ||
if (slots) { | ||
for (const [slot, value] of Object.entries(slots)) { | ||
if (slot === 'default') { | ||
yield `<astro-slot>${value || ''}</astro-slot>`; | ||
} else { | ||
yield `<astro-slot slot="${slot}">${value || ''}</astro-slot>`; | ||
} | ||
} | ||
} | ||
yield `</${tagName}>`; | ||
} | ||
async function renderToStaticMarkup(Component, props, children) { | ||
async function renderToStaticMarkup(Component, props, slots) { | ||
let tagName = Component; | ||
let out = ''; | ||
for (let chunk of render(tagName, props, children)) { | ||
for (let chunk of render(tagName, props, slots)) { | ||
out += chunk; | ||
@@ -72,0 +80,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25199
411