惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
IT之家
IT之家
C
Check Point Blog
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
F
Fortinet All Blogs
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
MyScale Blog
MyScale Blog
爱范儿
爱范儿
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)

CloudCannon Blog

Building with AI: Git-based vs headless vs traditional CMS CloudCannon + Astro: performance meets powerful content management Introducing the Astro Component Starter Introducing Jetstream — built on the Astro Component Starter Why we switched to the system font stack Redesigning CloudCannon’s docs with Diátaxis, Lume, and Pagefind Make content editing more visual: upgraded Editable Regions How Configuration Mode makes building editing interfaces easy Your hosting just got an upgrade (and a price cut) Custom testing domains for professional branding Keep your content consistent with input validation Managing multilingual content in CloudCannon Simplify team publishing with conflict resolution and domain tools Open Beta: Publishing Conflict Resolution Getting started with CloudCannon and Astro: Bookshop, components, and live editing Welcome to the CloudCannon Community! Omnichannel delivery is just marketing spin from API-based CMS companies Getting started with CloudCannon and Astro: Snippets and Collections Managing digital assets in CloudCannon: a guide to smart asset storage Understanding CloudCannon's branching workflows and Projects: a complete guide What is a static website? CloudCannon’s 2024 wrapped Getting started with CloudCannon and Astro: WYSIWYG blogging Jamstack vs. WordPress: reasons to make the change The top five static site generators for 2025 (and when to use them!) Free Jekyll themes for 2025: ten great community options Eleventy (11ty) vs. Hugo How to set up WYSIWYG editing with MkDocs Material The rise of static-first websites: why major brands are making the switch Watching your Core Web Vitals on Jamstack
Let’s create a microblog with visual editing using Booksh...
2023-12-08 · via CloudCannon Blog

Visual editing is table stakes for a modern content management workflow. Using CloudCannon, it’s straightforward to add visual editing to your project using the same workflow your development team already loves.

Visual editing empowers editors to feel confident when building content inside of the CMS and having that content look identical when it is pushed to production.

To get visual editing up and running with CloudCannon, we’ll use a plugin called Bookshop. In the guides section of the CloudCannon documentation you can find a section dedicated to Bookshop, with guides specifically for Astro and Eleventy.

Let’s make a Microblog Direct link to this section

In this post we’re going to go through the minimum viable steps to add Bookshop Visual Editing to an Eleventy Microblog (think something akin to Tumblr).

You can head over to GitHub to read through the final source code of the Microblog project. Feel free to fork the repository and deploy your own version to CloudCannon to try this out for yourself!

live demo of the final product is also available (with a few sample posts). Editors can add any arbitrary HTML content to the blog and the project includes pages for the content stream, individual posts, tags, and also on-page search (via Pagefind).

Set up Bookshop Direct link to this section

Scaffolding Direct link to this section

To create the initial Bookshop component files and folder structure, you can run the following command to populate the _component-library folder:

npx @bookshop/init --new _component-library --framework eleventy

Installation Direct link to this section

Next, let’s install our Bookshop dependencies. You can install everything you need for Bookshop with this command:

npm install --save-dev --save-exact @bookshop/eleventy-bookshop @bookshop/sass @bookshop/generate @bookshop/eleventy-engine npm-run-all
  • @bookshop/eleventy-bookshop to add Bookshop shortcodes to Eleventy.

  • @bookshop/sass to compile our Sass stylesheets.

  • @bookshop/generate @bookshop/eleventy-engine to enable Live Editing features on CloudCannon (these are not necessary for local development)

  • npm-run-all: (not Bookshop-specific) used during local development to run Eleventy and our Sass compiler side-by-side

Eleventy Configuration Direct link to this section

Next we’ll want to add Bookshop’s Eleventy plugin to our Eleventy configuration file (likely .eleventy.js or eleventy.config.js) the same as you would any other Eleventy plugin.

const pluginBookshop = require("@bookshop/eleventy-bookshop");

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(pluginBookshop({
bookshopLocations: ["_component-library"]
}));
};

The bookshopLocations configuration property must match the folder name specified in our scaffolding command (npx @bookshop/init …) above.

Compiling Sass Direct link to this section

We’ll also need to compile our Bookshop component styles, which you can do with the bookshop-sass command in these handy npm script additions to your package.json:

{
"scripts": {
"build:style": "bookshop-sass --bookshop _component-library --output _site/public/bookshop.css",
"dev:style": "npm run build:style -- --watch",
"dev:content": "npx @11ty/eleventy --serve --quiet",
"start": "run-p dev:*"
}
}

Now we simply run npm start to start Eleventy’s local development server and Bookshop is running locally!

CloudCannon Build Hooks Direct link to this section

Finally, we’ll add two CloudCannon build hooks to run our Bookshop integrations on the CloudCannon servers. We will create two files: .cloudcannon/prebuild and .cloudcannon/postbuild.

.cloudcannon/prebuild:

#!/usr/bin/env bash

npm install
npm run build:style

.cloudcannon/postbuild:

#!/usr/bin/env bash

npx @bookshop/generate

Using Bookshop Direct link to this section

Now that our setup is complete we can move on to the fun part: creating Bookshop components. At time of writing, our Microblog project has three Bookshop components: text, code, and link.

You can view the source code for our finished Microblog components for codelink, and text.

The simplest of these is the text component which holds on to no more than plain ol’ HTML content. Each Bookshop component can be represented in three files and text is no exception:

  • text.bookshop.yml for CloudCannon specific configuration (including input types).

  • text.eleventy.liquid for Liquid templating syntax for the component.

  • text.scss for component styles.

When we make changes to the HTML content in a text component in the CloudCannon interface, the visual rendering of the component will be updated in real time in the visual editor.

If you’d like to see a preview of how the visual editing experience looks and behaves, skip to 0:46 in this video on YouTube (or watch below).

You can mix and combine these Bookshop components together to create a post on the blog and the values for each of the component instances are serialized as content_blocks in the template’s front matter (view a sample post).

Works With Web Components Direct link to this section

Perhaps more interestingly, the link Bookshop component uses the <browser-window> web component and is editable without any configuration or introspection into the web component’s code — and this example demonstrates re-rendering compatibility with Shadow DOM web components too.

Any changes to the link URL are automatically reflected in the web component and the screenshot with favicon are updated accordingly.

Current Limitations Direct link to this section

Shortcodes are not supported in Bookshop components. Guarding the shortcode with env_bookshop_live is not yet a viable workaround. This is a Liquid limitation with parsing unknown shortcode names that we hope to fix soon. Try to switch your shortcode to use a filter instead and it will work fine.

That’s it! Direct link to this section

We now have a visual editing interface for our Microblog. Editors can now add or edit entries easily and predictably — but there is more! On the full Bookshop guide you can learn more about data binding, live editing fallbacks, custom plugins, preview thumbnails, and the component playground (everybody loves a style guide!).

Poster image photo by Ivo Rainha.