getgrav / grav-plugin-anchors Goto Github PK
View Code? Open in Web Editor NEWGrav Anchors Plugin
Home Page: https://getgrav.org
License: MIT License
Grav Anchors Plugin
Home Page: https://getgrav.org
License: MIT License
anchor.js
isn't a jQuery
plugin, it's a vanilla js
plugin! (no dependencies at all)
I noticed that Anchors will not convert diacritics (accented characters like à, é, ü, or others like ç) but drops them.
For instance, on this page "Colophon" will correctly render as info#colophon
, but "Mentions légales" will become info#mentions-lgales
— notice how the "é" was not converted into an "e"?
Anchors are not very visible to the end-user, of course, but this is a bit awkward when creating links by hand to anchors elsewhere on our sites. For the example above, I'd have expected the anchor to be info#mentions-legales
instead of info#mentions-lgales
.
If this could help you, the TOC plugin does this conversion correctly (but "uglifies" anchors by underlining them - and I prefer your visual to indicate them anyway)
Not a show-stopper, but it would be nice if you could manage to correct this.
Thank you anyway, and best regards!
I cannot disable anchorjs in my custom error 404 page.
You can find the exact page setup I'm using here: https://github.com/RojerGS/mathspp/tree/master/pages/error.
And you can test it by accessing a random route in my website, e.g. https://mathspp.com/agadfasdfasdfaff.
My frontmatter.yaml
looks like this:
anchors:
active: false
enabled: false
http_response_code: 404
metadata:
author: Rodrigo Girão Serrão
routable: false
and my default.en.md
looks like this:
---
title: Error
---
<center><h1>Error 2×2×101</h1>
Woops. Looks like this page doesn't exist.
</center>
But for some reason, the anchor to the h1 title is there.
It would be good to get filter by the page template types
When adding special characters like öäü the php twig extension filters those out, but the javascript code does not. This results in broken links inside the index table.
Disclaimer: i know nothing of JS, very little about Grav and less about github (=
Found that i had some problems with the swedish special chars "Å Ä Ö" in the anchor links and the auto-generated menu.
Solved this by adding
'å','ä',
to the "$rx1 = array" of AnchorsTwigExtension.php
and adding
.replace(/å/g, '').replace(/Å/g, '').replace(/ä/g, '').replace(/Ä/g, '').replace(/ö/g, '').replace(/Ö/g, '')
just before .toLowerCase() in anchors.min.js
Is this me not using the plugin the right way or is there a need for updates similar to the above?
Did not make a pull-request because i'm not sure how to actually do it and almost certain there is a better way to do these changes.
Hello, thanks for you job.
I'm really sorry but i'don't understand your demonstration.
just put the function below in the template file twig:
anchors(content, tag, terms)
Do you share example ? i'm not a good developper so i need more.
Dont confuse this with #20 which is related to javascript, not the twig php extension.
The current code ignores the truncate
setting in the config completely. It shorts ids to 64 characters and titles to 50 - always.
anchors should be disabled on the admin pages
Can confirm that file doesn't exist locally (though I noticed it does here). Install looks to otherwise perfectly fine, and plugin appears to run correctly. Failing command follows:
root@e881e4b4fb57:/usr/share/nginx/html# bin/gpm install -y error problems breadcrumbs anchors highlight simplesearch learn2
GPM Releases Configuration: Stable
Preparing to install Error [v1.6.0]
|- Downloading package... 100%
|- Checking destination... ok
|- Installing package... ok
'- Success!
Preparing to install Problems [v1.4.7]
|- Downloading package... 100%
|- Checking destination... ok
|- Installing package... ok
'- Success!
Preparing to install Breadcrumbs [v1.5.1]
|- Downloading package... 100%
|- Checking destination... ok
|- Installing package... ok
'- Success!
Preparing to install Anchors [v1.5.2]
|- Downloading package... 100%
|- Checking destination... ok
|- Installing package...
[RuntimeException]
copy(/usr/share/nginx/html/user/plugins/anchors/.idea/vcs.xml): failed to open stream: No such file or directory
I noticed that a recent commit introduced the file its complaining about. No idea how Grav works underneath, but is it possible the new file is giving it grief?
Hello,
I'm trying to have an auto-generated menu like explained in the docs.
Problem:
Too few arguments to function Grav\Plugin\AnchorsTwigExtension::anchorsFunction(), 2 passed in XXX\user\plugins\anchors\twig\AnchorsTwigExtension.php on line 63 and exactly 3 expected
What I did:
{{ anchors(page.content, 'li') }}
in my .md
file.md
fileprocess:
twig: true
It seems like I'm missing an argument, but even if I write {{ anchors(page.content, 'li', '') }}
I have the same error.
Am I missing something ?
PS: Everything is up to date
Please update to the last version of anchorJs because some éléments of the official documentation are not compatible with the version provided with the plugin.
Happily , a manuel update is possible just by replacing the anchor.min.js file by the latest version avalaible
I have long headlines and they are only truncated in the twig function, but not in the javascript. So the index table does not work properly for some headlines.
The installation instructions mention user/plugins/breadcrumbs/anchors.yaml
which should be user/plugins/anchors/anchors.yaml
.
I just noticed the anchor.js version in this repo is 1.2.1, while the original anchor.js project has reached version 3.2.2
https://github.com/bryanbraun/anchorjs/releases
time for an update?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.