diff --git a/sample/my-sample.html b/sample/my-sample.html new file mode 100644 index 0000000..6e05cdc --- /dev/null +++ b/sample/my-sample.html @@ -0,0 +1,64 @@ +--- +title: Sample documents of extention "WordPress Post" +status: publish +date: "2021-12-31T23:00:00" +categories: [vscode] +tags: [vscode, typescript] +--- + +
This is sample document of extention "WordPress Post". + Test of Line Break.
+Test of new paragraph.
+Test of headline level 2.
+Test of headline level 3.
+
+
+ import requests
+ SITE_URL = "https://yoursite"
+ API_URL = f"{SITE_URL}/wp-json/wp/v2/"
+ AUTH_USER = "zzzz"
+ AUTH_PASS = "xxxx xxxx xxxx xxxx xxxx IxxxxYT4"
+
+ res = requests.get(API_URL, auth=(AUTH_USER, AUTH_PASS))
+ print(res.json())
+
+
+
+| label | +API | +
|---|---|
| category | +/wp-json/wp/v2/categories | +
| tag | +/wp-json/wp/v2/tags | +
| media | +/wp-json/wp/v2/media | +
| post | +/wp-json/wp/v2/posts | +
Abount local(relative path) image, this extention uploads and replaces local url to wordpress url:
+
Abount www() image, this extension is ignore this.
+That's all.
\ No newline at end of file diff --git a/src/post.ts b/src/post.ts index bea7df2..e90f49a 100644 --- a/src/post.ts +++ b/src/post.ts @@ -29,8 +29,8 @@ export const post = async (context: Context) => { // check document file extension context.debug(`[03S] check file extension`); - if (docParsedPath.ext !== ".md") { - const msg = `Not a Markdow file: ${docParsedPath.base}`; + if (docParsedPath.ext !== ".md" && docParsedPath.ext !== ".html") { + const msg = `Not a Markdow or Html file: ${docParsedPath.base}`; context.debug(`[03Z] ${msg}`); throw new Error(msg); } @@ -69,10 +69,18 @@ export const post = async (context: Context) => { } context.debug(`[04E] detected document slug : ${postData["slug"]}`); - // markdown -> post data content - context.debug(`[06S] convert to html`); - postData["content"] = MarkdownIt().render(markdown.content); - context.debug(`[06E] converted to html`); + // document content + if(docParsedPath.ext === ".md") + { + // markdown -> post data content + context.debug(`[06S] convert to html`); + postData["content"] = MarkdownIt().render(markdown.content); + context.debug(`[06E] converted to html`); + } + if(docParsedPath.ext === ".html") + { + postData["content"] = markdown.content; + } // upload attached image file, change src context.debug(`[07S] process attached images`);