Giter VIP home page Giter VIP logo

docpad-plugin-navlinks's People

Contributors

lucor avatar pvandervelde avatar robloach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docpad-plugin-navlinks's Issues

Two flaws

(1)

navLinks = @getDocument().get('navlinks')

This needs an "if (navLinks != null)" wrapping the subsequent block as not all pages may end up with navlinks.

(2)

The "Next post" text is followed by the wrong title:

<a href="#{navLinks.url.next}" title="Next Post: #{navLinks.title.prev}" ...

s/prev/next/

ReferenceError: docpad not defined

Just upgraded to the latest version of docpad (6.65.0) and latest version of all my plugins. Prior to the upgrade building the website worked fine. After the upgrade I get the following error:

ReferenceError: docpad is not defined
  at NavLinksPlugin.renderBefore (C:\documents\personal\mindvortex\src\node_modules\docpad-plugin-navlinks\out\navlinks.plugin.js:30:11)
  at ambi (C:\documents\personal\mindvortex\src\node_modules\docpad\node_modules\event-emitter-grouped\node_modules\ambi\out\lib\ambi.js:23:18)
  at Task.<anonymous> (C:\documents\personal\mindvortex\src\node_modules\docpad\node_modules\event-emitter-grouped\out\lib\event-emitter-grouped.js:45
:23)
  at ambi (C:\documents\personal\mindvortex\src\node_modules\docpad\node_modules\event-emitter-grouped\node_modules\ambi\out\lib\ambi.js:23:18)
  at fire (C:\documents\personal\mindvortex\src\node_modules\docpad\node_modules\event-emitter-grouped\node_modules\taskgroup\out\lib\taskgroup.js:174
:25)
  at b (domain.js:183:18)
  at Domain.run (domain.js:123:23)
  at Task.fire (C:\documents\personal\mindvortex\src\node_modules\docpad\node_modules\event-emitter-grouped\node_modules\taskgroup\out\lib\taskgroup.j
s:184:25)
  at processImmediate [as _immediateCallback] (timers.js:336:15)

The configuration looks like:

# The DocPad Configuration File
# It is simply a CoffeeScript Object which is parsed by CSON
docpadConfig = {
    # =================================
    # plugins

    plugins:
        navlinks:
            collections:
                posts: -1

        datefromfilename:
            removeDate: false

    # =================================
    # DocPad collections

    collections:

        pages: ->
             @getCollection("html").findAllLive({isPage:true},[{order:1}]).on "add", (model) ->
                model.setMetaDefaults({layout:"default"})

        posts: (database) ->
            database.findAllLive({relativeOutDirPath:'posts'},[{date:-1}]).on "add", (model) ->
                model.setMetaDefaults({layout:"post"})

        projects: ->
            @getCollection('html').findAllLive({relativeOutDirPath:'projects'},[{title:1}]).on "add", (model) ->
                model.setMetaDefaults({layout:"project"})

        frontpage: ->
            @getCollection("html").findAllLive({relativeOutDirPath: $in: ['posts','projects']},[{date: -1}])

    # =================================
    # Template Data
    # These are variables that will be accessible via our templates
    # To access one of these within our templates, refer to the FAQ: https://github.com/bevry/docpad/wiki/FAQ

    templateData:

        # Specify some site properties
        site:
            # The production url of our website
            url: "http://www.petrikvandervelde.nl"

            # Here are some old site urls that you would like to redirect from
            oldUrls: ["http://pvandervelde.github.io/"]

            # The default title of our website
            title: "Mind Vortex"


        # -----------------------------
        # Helper Functions

        # Get the prepared site/document title
        # Often we would like to specify particular formatting to our page's title
        # we can apply that formatting here
        getPreparedTitle: ->
            # if we have a document title, then we should use that and suffix the site's title onto it
            if @document.title
                "#{@document.title} | #{@site.title}"
            # if our document does not have it's own title, then we should just use the site's title
            else
                @site.title

        # Get the prepared site/document description
        getPreparedDescription: ->
            # if we have a document description, then we should use that, otherwise use the site's description
            @document.description or @site.description

        # Get the prepared site/document keywords
        getPreparedKeywords: ->
            # Merge the document keywords with the site keywords
            @site.keywords.concat(@document.keywords or []).join(', ')

    # =================================
    # DocPad Events

    # Here we can define handlers for events that DocPad fires
    # You can find a full listing of events on the DocPad Wiki
    events:

        # Server Extend
        # Used to add our own custom routes to the server before the docpad routes are added
        serverExtend: (opts) ->
            # Extract the server from the options
            {server} = opts
            docpad = @docpad

            # As we are now running in an event,
            # ensure we are using the latest copy of the docpad configuraiton
            # and fetch our urls from it
            latestConfig = docpad.getConfig()
            oldUrls = latestConfig.templateData.site.oldUrls or []
            newUrl = latestConfig.templateData.site.url

            # Redirect any requests accessing one of our sites oldUrls to the new site url
            server.use (req,res,next) ->
                if req.headers.host in oldUrls
                    res.redirect(newUrl+req.url, 301)
                else
                    next()
}

# Export our DocPad Configuration
module.exports = docpadConfig

Date::getMonthName = () ->
  months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
  months[this.getMonth()]

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.