writefreely / hugo-importer Goto Github PK
View Code? Open in Web Editor NEWCLI tool for migrating Hugo content to Write.as/WriteFreely
License: GNU General Public License v3.0
CLI tool for migrating Hugo content to Write.as/WriteFreely
License: GNU General Public License v3.0
The project should include a suite of unit tests that ensure everything's working as expected.
Tests should be included for the following files:
When a command-line flag (--images
) is set, the hugo-importer
tool should upload local images to Snap.as and update image links in the source content.
This feature is only available to Write.as Pro subscribers. At a minimum, if the --instance
flag is set, the tool should return an error.
There are two main ways to include an image in the source content, and the tool should handle both:
1. Using Markdown (!["Alt text here"](/link/to/image.jpeg)
)
2. Using HTML (<img src="/link/to/image.jpeg" alt="Alt text here" />
)
If the --images
flag is set, the tool shall do the following when parsing a source file:
/static/link/to/image.jpeg
Related to step 2 in the implementation details above, a local image's source may be represented via an absolute path (https://example.com/link/to/image.jpeg
), or a relative path (/link/to/image.jpeg
). In the latter case, it's clear that the image is local; in the former, however, the tool must determine if the base URL (in this scenario, example.com
) is the URL of the Hugo site being migrated. Fortunately, the baseURL
parameter in the Hugo site configuration file lets us make this comparison.
This project requires, at a minimum, the following documentation:
Hugo provides built-in shortcodes that "represent very common usage" for convenience. The intention is to keep Markdown clean, but because they are proprietary to Hugo, they don't migrate nicely, so a Tweet shortcode ends up looking like:
{{< tweet 877500564405444608 >}}
Where possible, these would make more sense as plain URLs:
https://twitter.com/twitter/status/877500564405444608
For a subset (e.g. gist
, tweet
, and youtube
), converting shortcodes to URLs allows Pro users to get proper embeds via embed.as; in all cases, special care must be taken to craft a valid URL from the shortcode, so we'll limit ourselves to the following shortcodes:
Media | Hugo Shortcode | URL | Embed.as? |
---|---|---|---|
GitHub Gist | {{< gist username gistID >}} |
https://gist.github.com/username/gistID |
✅ |
{{< instagram photoID >}} |
https://www.instagram.com/p/photoID/ |
⛔️ | |
{{< tweet tweetID >}} |
https://twitter.com/twitter/status/tweetID |
✅ | |
Vimeo | {{< vimeo videoID >}} |
https://player.vimeo.com/video/videoID |
⛔️ |
YouTube | {{< youtube videoID >}} |
https://www.youtube.com/watch?v=videoID |
✅ |
This doesn't cover all built-in shortcodes, nor does it cover all options for the shortcodes listed above, but I believe it's a pretty solid set of shortcodes to cover for launch. We can include a note in the README about this limitation, and extend it if the demand exists.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.