-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP post.njk to webc conversion, log collison template bugs
_components/html/h2.webc: `console.log(slots.text.default);` See 11ty/webc#151 for more on collisions
- Loading branch information
Showing
15 changed files
with
125 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
<link rel="stylesheet" href="heading.css"> | ||
<script webc:type="js" webc:root="override"> | ||
let slug = slugify(slots.text.default); | ||
`<h2 id="${slug}"> | ||
<a href="#${slug}" class="heading-link"><span aria-hidden="true">#</span><visually-hidden>anchor</visually-hidden></a> | ||
${slots.text.default} | ||
</h2>` | ||
</script> | ||
<script webc:type="js"> | ||
console.log('$data.page.url:'); | ||
console.log($data.page.url); | ||
console.log('webc:'); | ||
console.log(webc.attributes); | ||
console.log('slots.text.default:'); | ||
console.log(slots.text.default); | ||
console.log('\n'); | ||
|
||
`${slots.text.default}` | ||
</script> | ||
<h2 @attributes webc:root="override"> | ||
<a href="#" class="heading-link"><span aria-hidden="true">#</span></a> | ||
<slot></slot> | ||
</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<link rel="stylesheet" href="heading.css"> | ||
<script webc:type="js" webc:root="override"> | ||
let slug = slugify(slots.text.default); | ||
`<h3 id="${slug}"> | ||
<a href="#${slug}" class="heading-link"><span aria-hidden="true">#</span><visually-hidden>anchor</visually-hidden></a> | ||
${slots.text.default} | ||
</h3>` | ||
</script> | ||
<h3 @attributes webc:root="override"> | ||
<a href="#" class="heading-link"><span aria-hidden="true">#</span></a> | ||
<slot></slot> | ||
</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<link rel="stylesheet" href="heading.css"> | ||
<script webc:type="js" webc:root="override"> | ||
let slug = slugify(slots.text.default); | ||
`<h4 id="${slug}"> | ||
<a href="#${slug}" class="heading-link"><span aria-hidden="true">#</span><visually-hidden>anchor</visually-hidden></a> | ||
${slots.text.default} | ||
</h4>` | ||
</script> | ||
<h4 @attributes webc:root="override"> | ||
<a href="#" class="heading-link"><span aria-hidden="true">#</span></a> | ||
<slot></slot> | ||
</h4> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.heading-link { | ||
font-size: 1.125rem; /* 18px /16 */ | ||
text-decoration: none; | ||
padding: .1em .2em .1em 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<style webc:scoped> | ||
/* https://www.a11yproject.com/posts/how-to-hide-content/ */ | ||
:host { | ||
clip: rect(0 0 0 0); | ||
clip-path: inset(50%); | ||
height: 1px; | ||
overflow: hidden; | ||
position: absolute; | ||
white-space: nowrap; | ||
width: 1px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
---node | ||
templateEngineOverride: md,webc | ||
const layout = "layouts/base.njk"; | ||
const previousPost = getPreviousCollectionItem(collections.posts); | ||
const nextPost = getNextCollectionItem(collections.posts); | ||
--- | ||
<!-- {%- css %} | ||
/* Only include the syntax highlighter CSS on blog posts */ | ||
{% include "node_modules/prismjs/themes/prism-okaidia.css" %} | ||
{% include "public/css/prism-diff.css" %} | ||
{%- endcss %} --> | ||
<figure> | ||
<!-- {%- if hero and heroalt %} | ||
|
||
{%- if herolink %} --> | ||
<a :href="herolink"> | ||
<!-- {%- endif %} | ||
|
||
{% image hero, heroalt %} | ||
|
||
{%- if herolink %} --> | ||
</a> | ||
<!-- {%- endif %} | ||
|
||
{%- if herocaption %} --> | ||
<figcaption> | ||
<!-- {%- if herolink %} --> | ||
<a :href="herolink" @text="herocaption"></a> | ||
<!-- {%- endif %} --> | ||
</figcaption> | ||
<!-- {%- endif %} | ||
{%- endif %} --> | ||
</figure> | ||
<h1 @text="title"></h1> | ||
|
||
<ul class="post-metadata"> | ||
<li><time :datetime="htmlDateString(page.date)" @text="readableDate(page.date)"></time></li> | ||
<div webc:for="filterTagList(tag of tags)"> | ||
<li> | ||
<a :href="`/tags/${slugify(tag)}`" class="post-tag" @text="tag"></a> | ||
</li> | ||
</div> | ||
</ul> | ||
|
||
<div @html="content" webc:nokeep></div> | ||
|
||
<!-- {%- if collections.posts %} --> | ||
<!-- {%- if nextPost or previousPost %} --> | ||
<ul class="links-nextprev"> | ||
<!-- {%- if previousPost %} --> | ||
<li>Previous: <a :href="previousPost.url" @text="previousPost.data.title"></a></li> | ||
<!-- {% endif %} --> | ||
<!-- {%- if nextPost %} --> | ||
<li>Next: <a :href="nextPost.url" @text="nextPost.data.title"></a></li> | ||
<!-- {% endif %} --> | ||
</ul> | ||
<!-- {%- endif %} --> | ||
<!-- {%- endif %} --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
---node | ||
const layout = "layouts/base.njk"; | ||
--- | ||
<div webc:if="hero && heroalt" webc:nokeep> | ||
<figure> | ||
<a :href="herolink"> | ||
<img webc:is="eleventy-image" :src="hero" :alt="heroalt"> | ||
</a> | ||
<figcaption @text="herocaption"></figcaption> | ||
</figure> | ||
</div> | ||
<h1 @text="title"></h1> | ||
|
||
<ul class="post-metadata"> | ||
<li><time :datetime="htmlDateString(page.date)" @text="readableDate(page.date)"></time></li> | ||
</ul> | ||
|
||
<div @html="content" webc:nokeep></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
let data = { | ||
tags: ["posts"], | ||
layout: "layouts/post.njk", | ||
layout: "layouts/test.webc", | ||
}; | ||
|
||
export default data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes