|
24 | 24 |
|
25 | 25 | ## Usage |
26 | 26 |
|
27 | | -```sh |
| 27 | +```bash |
28 | 28 | % hudevto help |
29 | 29 | hudevto allows you to synchronize your Hugo posts with your DEV articles. The |
30 | 30 | synchronization is one way (Hugo to DEV). A Hugo post is only pushed when a |
31 | | -change is detected. When pushed to DEV, the Hugo article is applied two |
32 | | -transformations: the relative image links are absolutified, and the Hugo tags |
33 | | -are turned into Liquid tags. |
| 31 | +change is detected. When pushed to DEV, the Hugo article is transformed a bit, |
| 32 | +e.g., relative image links are absolutified (see TRANSFORMATIONS). |
| 33 | + |
| 34 | +COMMANDS |
| 35 | + |
| 36 | + hudevto status [POST] |
| 37 | + Shows the status of each post (or of a single post). The status shows |
| 38 | + whether it is mapped to a DEV article and if a push is required when the |
| 39 | + Hugo post has changes that are not on DEV yet. |
34 | 40 |
|
35 | | -USAGE |
36 | | - hudevto [OPTION] (preview|diff) POST |
37 | | - hudevto [OPTION] status [POST] |
38 | | - hudevto [OPTION] push [POST] |
39 | | - hudevto [OPTION] devto list |
| 41 | + hudevto preview [POST] |
| 42 | + Displays a Markdown preview of the Hugo post that has been converted into |
| 43 | + the DEV article Markdown format. You can use this command to check that |
| 44 | + the tranformations were correctly applied. |
| 45 | + |
| 46 | + hudevto diff [POST] |
| 47 | + Displays a diff between the Hugo post and the DEV article. It is useful |
| 48 | + when you want to see what changes will be pushed. |
| 49 | + |
| 50 | + hudevto push [POST] |
| 51 | + Pushes the given Hugo Markdown post to DEV. If no post is given, then |
| 52 | + all posts are pushed. |
| 53 | + |
| 54 | + hudevto devto list |
| 55 | + Lists all the articles you have on your DEV account. |
| 56 | + |
| 57 | +IMPORTANT |
| 58 | + |
| 59 | +hudevto has been mainly built for pushing https://maelvls.dev, and the following |
| 60 | +assumptions are made: |
| 61 | + |
| 62 | +1. Each blog post is in its own folder and the article itself is in index.md, |
| 63 | + e.g. ./content/post-1/index.md. |
| 64 | +2. The images are hosted along with the index.md file. |
| 65 | +3. The base_url is set in config.yml. |
| 66 | +4. Each article has the "url" field set in its front-matter. |
| 67 | + |
| 68 | +HOW TO USE IT |
40 | 69 |
|
41 | | -DESCRIPTION |
42 | 70 | In order to operate, hudevto requires you to have your DEV account configured |
43 | 71 | with "Publish to DEV Community from your blog's RSS". You can configure that at |
44 | 72 | https://dev.to/settings/extensions. DEV will create a draft article for |
@@ -89,24 +117,49 @@ Finally, you can push to DEV: |
89 | 117 | success: ./content/cloth-impossible.md pushed to https://dev.to/maelvls/cloth-impossible-95dc |
90 | 118 | success: ./content/powder-farmer.md pushed to https://dev.to/maelvls/powder-farmer-6a18 |
91 | 119 |
|
| 120 | +TRANSFORMATIONS |
| 121 | +The Markdown for Hugo posts and dev.to articles have slight differences. |
| 122 | +Before pushing to dev.to, hudevto does some transformations to the Markdown |
| 123 | +file. To see the transformations before pushing the Hugo post to dev.to, use one of: |
92 | 124 |
|
93 | | -COMMANDS |
94 | | - hudevto status [POST] |
95 | | - Shows the status of each post (or of a single post). The status shows |
96 | | - whether it is mapped to a DEV article and if a push is required when the |
97 | | - Hugo post has changes that are not on DEV yet. |
98 | | - hudevto preview POST |
99 | | - Displays a Markdown preview of the Hugo post that has been converted into |
100 | | - the DEV article Markdown format. You can use this command to check that |
101 | | - the tranformations were correctly applied. |
102 | | - hudevto diff POST |
103 | | - Displays a diff between the Hugo post and the DEV article. It is useful |
104 | | - when you want to see what changes will be pushed. |
105 | | - hudevto push [POST] |
106 | | - Pushes the given Hugo Markdown post to DEV. If no post is given, then |
107 | | - all posts are pushed. |
108 | | - hudevto devto list |
109 | | - Lists all the articles you have on your DEV account. |
| 125 | + % hudevto diff ./debug-k8s/index.md |
| 126 | + |
| 127 | +The transformations are: |
| 128 | + |
| 129 | +1. ABSOLUTE MARKDOWN IMAGES: the relative image links are absolutified since |
| 130 | + dev.to needs the image path to be absolute (the base URL itself is not |
| 131 | + required). |
| 132 | + |
| 133 | + The following Hugo Markdown snippet: |
| 134 | + |
| 135 | +  |
| 136 | + |
| 137 | + becomes: |
| 138 | + |
| 139 | +  |
| 140 | + <--(1)---> |
| 141 | + |
| 142 | + where (1) is the article's Hugo permalink to the ./debug-k8s/index.md post. |
| 143 | + Note that the ![]() tag must span a single line. Otherwise, it won't be |
| 144 | + transformed. |
| 145 | + |
| 146 | +2. ABSOLUTE HTML IMG TAGS: unlike with Markdown images, the <img> HTML tags |
| 147 | + need to be absolute and needs to contain the base URL. For example, the |
| 148 | + following HTML: |
| 149 | + |
| 150 | + <img src="wireshark.png"> |
| 151 | + |
| 152 | + gets transformed to: |
| 153 | + |
| 154 | + <img src="https://maelvls/debug-k8s/wireshark.png"> |
| 155 | + |
| 156 | + The <img> tag must be on a single line, and the "src" value must end with |
| 157 | + one of the following extensions: png, PNG, jpeg, JPG, jpg, gif, GIF, svg, |
| 158 | + SVG. |
| 159 | + |
| 160 | +3. SHORTCODES: Hugo shortcodes for embedding (like for embedding a Youtube video) |
| 161 | + are turned into Liquid tags that dev.to knows about. |
| 162 | +4. ANCHOR IDS: Hugo and Devto have different anchor ID syntaxes. |
110 | 163 |
|
111 | 164 | OPTIONS |
112 | 165 | -apikey string |
|
0 commit comments