Comments (7)
update from a conversation with @emmenko about how to approach the topic:
- we will go for an import and webpack-based approach. Users learn the import notation and have to lean it anyways for MDX transclusion.
- code examples from outside the repository will be provided via a special package in the respective content repository which pulls the examples from whereever they live (e.g. the repository of an SDK) and then provides the files as a javascript package.
I'll update the issue description here
FYI @davifantasia
from commercetools-docs-kit.
I just want to say I started working on this.
from commercetools-docs-kit.
To be able to implement this:
import CartCreateExampleJs from '@commercetools-docs/code-examples/javascript/cart/create.js'
import CartCreateExampleJava from '../../code-examples/java/cart/create.java'
<CartCreateExampleJs title="Creating a Cart in Javascript" />
<CartCreateExampleJava highlightLines="5-10" title="Creating a Cart in Java" />
I looked into exporting CodeBlock component from a webpack loader. I mainly used this plugin as a base, because it pretty much has a similar process compared to what we want to achieve:
https://github.com/gregberge/svgr/blob/master/packages/webpack
My conclusion is that I have to understand how Babel transpiles both ES6 and React. At least for now, I donβt think itβs worth the effort.
from commercetools-docs-kit.
Current solution proposal:
Expose a AutoCodeExample component which authors can then use like so:
<AutoCodeExample import="@package/path/to/sample-code.js" title="JavaScript Code Sample" />
<AutoCodeExample import="/path/to/sample-code.java" />
AutoCodeExample
- name was chosen after discussing with @adinakleine , since this tool is author-centric.
This component would only work with a simple webpack loader tool that returns file contents as a string which the component can then render as content of a code block.
from commercetools-docs-kit.
In the PR #299 you only load code examples from a local folder. What about external files?
from commercetools-docs-kit.
In the PR #299 you only load code examples from a local folder. What about external files?
That is still a draft PR. I appreciate early review but in this case I suggest you wait until I mark it as ready for review.
from commercetools-docs-kit.
I still had trouble implementing this task by taking advantage of building a webpack plugin. So I sat down with @jenschude to find a solution, after that I decided on a different approach. Please see the PR here - #300
from commercetools-docs-kit.
Related Issues (20)
- [AI] Fix the assistant API for docs-kit production HOT 1
- π Add the Metadata of a microsite into the html HOT 2
- Bug with collapsible chapters
- Add Foundry lord-icon to the kit
- Expanding a sub-chapter opens another sub-chapter HOT 4
- [SLC] Rename microsite to 'Certifications'
- AiAssistant: broken readOnly Mode
- 404 links on GitHub not detected by external link checker
- Left-hand navigation title menu is too small for long names
- Improve accessibility of login button
- Enum description is not rendered when enum value is `enum`
- Canonical tags are not added to the pages
- Remove learning-certification-renewal-program microsite from repository
- JustinBeckwith/linkinator-action node 20 update HOT 1
- Mermaid labels are cut in Chrome HOT 1
- Creating the onboarding plan for an ET Dev HOT 2
- External links identified incorrectly as internal links
- moodle code formatting (not a blocker, but a nice to have) HOT 1
- Using a module in multiple learning paths HOT 4
- Chrome: Search bar doesn't open on first load until after 5 seconds
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commercetools-docs-kit.