Project to build an API to manage the content from a site generated by hugo.
Path | Method | Description |
---|---|---|
/login |
POST | Receives username and password params and returns a token string |
/api |
GET | Infomations about this project |
/sections |
GET | List sections |
/content/:section |
GET | List content from section :section |
/content/:section |
POST 1 | Create a new content into section :section (also create the section if not exists) |
/content/:section/:slug |
GET 1 | Get content :slug from section :section |
/content/:section/:slug |
PUT 1 | Update content (slug property is imutable) |
/content/:section/:slug |
DELETE | Remove content |
/content/:section/:slug/attach |
POST | Add resource to content (input field must be called "attach") |
/content/:section/:slug/:attach |
GET | Get resource |
/content/:section/:slug/:attach |
DELETE | Discard resource and update respective content |
1 The default mimetype of response is "application/json
". If you want markdown, add the header "Accept: text/markdown
" to your request.
There are two ways to configure send2hugo
. The first is using a configuration file named send2hugo.json
(example here).
The file must be in JSON format and it's location be the same folder from he is called or -c
flag can be used to customize this path.
Variable | Default Value | Description |
---|---|---|
PORT |
8000 | Port to listen |
JWT_SECRET |
(empty) | Used to sign tokens |
CONTENT_FOLDER |
./content | Path to hugo content folder |
STATIC_FOLDER |
./public | Path to static folder (can be the public folder on hugo default hierarchy) |
AUTH_ENDPOINT |
(empty) | OpenID endpoint to authentication |
AUTH_CLIENT_ID |
(empty) | OpenID client identification |
AUTH_CLIENT_SECRET |
(empty) | OpenID client secret |
TOKEN_DURATION |
24 | Expiration time for token (in hours) |
MIMETYPES |
application/pdf,image/png,image/jpeg | List of allowed mime types (separeted by comma) |
P.S.: Pull Requests to improve security, add funcionalities or manage other folders (archetypes, layouts, themes, translations…) are welcome.
P.S.2: The OpenID authentication was tested only against a keycloak server.