GithubHelp home page GithubHelp logo

Comments (3)

krasimir avatar krasimir commented on June 1, 2024

It's actually possible to solve the problem. The value of preface variable is used in a Techy command. This means that we could do whatever we need with the string before to send it to the page. So, if we have the following code in our markdown:

---
date: 11-01-2014
title: An article with code
preface: Curabitur consequat <img src="{siteURL}themes/default/public/img/favicon.png" /> ligula iaculis elit aliquet tincidunt. Proin aliquet massa venenatis, porta lorem.
tags:
  - javascript
  - nodejs
---

We ma replace the {siteURL} marker with the actual path:

var articles = this.pages('articles', 'date');
var html = '', to = max || articles.length;
for(var i=0; i<to; i++) {
    var article = articles[i];
    html += this.template(template, {
        title: article.get('title'),
        preface: article.get('preface').replace('{siteURL}', this.get('paths').root),
        link: this.linkto(article),
        date: article.get('date'),
        tags: article.get('tags').join(', ')
    });
}

from techy.

krasimir avatar krasimir commented on June 1, 2024

I should mention that a Techy command is run in the context of the current page. So, this.get('paths').root is pointing to the right place. Actually the value of this root property is different for every page and depends on its position based on the root project's directory.

P.S.
let me know if the trick above works for you

from techy.

zalun avatar zalun commented on June 1, 2024

Solved - yes I figured it out from the code - cool

from techy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.