Skip to content

resource_link shortcode throws an error if you pass in a title #1387

@gumaerc

Description

@gumaerc

Expected Behavior

If I have a call to the resource_link shortcode in my content, i.e. ({{% resource_link "f6e70b41-9390-494c-a569-f825b3faa01e" "Inspiration" %}}), a link (a tag) should be generated with the text passed in the second argument.

Current Behavior

An error is thrown:

Error: error building site: assemble: "/tmp/build/ed66b15e/site-content-git/content/pages/image-galleries/jewelry-gallery.md:1:1": got positional parameter 'f6e70b41-9390-494c-a569-f825b3faa01e'. Cannot mix named and positional parameters

Steps to Reproduce

  1. Clone an existing content repo or make a new one
  2. Find a page or resource under the content folder and note its UUID
  3. On another page, link to it using the resource_link shortcode, passing the UUID in as the first argument and a title in as the second

Possible Solution

Pull out the expected arguments from .Params and set them explicitly when calling external_resource_link, rather than using merge

Additional Details

There is a method on shortcodes called .IsNamedParams (https://gohugo.io/templates/shortcode-templates/#isnamedparams) that can check if the shortcode has had named params passed to it. This may be helpful. I did my testing with 21m.715-fall-2009 after running the link_to_external_resource and nav_item_to_external_resource management commands in ocw-studio.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions