articles-adapter-pluxml

1.2.1 • Public • Published

articles-adapter-pluxml

Adapter to get informations from a pluXml cms

Install

npm install articles-adapter-pluxml

Usage

Instantiation with a local directory

const PluXmlAdapter = require("articles-adapter-pluxml"),
adapter = new PluXmlAdapter("/var/www/pluxml");

Getting all articles ids as an array of string

adapter.articles.getIds().then((ids)=>{
    console.log(ids);
});

Getting article by id

adapter.articles.getById("0001").then((article)=>{
    console.log(article);
});

Url rewriting

Url rewriting setting use sprintf syntax with the following arguments :

sprintf(rewriteRule, id, slug)

With an article having the following properties :

{id:"0001",slug:"article-slug"}

The following code rewrite url to http://example.com/1-article-slug.html

const adapter = new PluXmlAdapter({
    storage:"/var/www/pluxml",
    rewriteRule:"http://example.com/%d-%s.html"
});
adapter.articles.getById("0001").then((article)=>{
    console.log(article.url); // => http://example.com/1-article-slug.html
});

/articles-adapter-pluxml/

    Package Sidebar

    Install

    npm i articles-adapter-pluxml

    Weekly Downloads

    2

    Version

    1.2.1

    License

    GPL-3.0

    Unpacked Size

    76.8 kB

    Total Files

    20

    Last publish

    Collaborators

    • petitchevalroux