3
1
Fork
You've already forked experimental-plugins
1

add plugin for checking broken links #39

Merged
iacore merged 7 commits from check_links into main 2024年06月26日 23:47:56 +02:00
iacore commented 2024年06月25日 19:11:55 +02:00 (Migrated from github.com)
Copy link

it works on my end
quality not guaranteed

it works on my end quality not guaranteed
iacore commented 2024年06月25日 20:31:27 +02:00 (Migrated from github.com)
Copy link

it works with resolve_urls
nice!

it works with resolve_urls nice!

This loop is executed for every url found in the html code. It should be moved outside this function and run only once. For example:

const urls = new Set<string>(); // Set is more performant than arrays

site.process("*", (pages) => {
 url.clear(); // Clear on rebuild
 for (const page of pages) {
 urls.add(site.url(page.data.url, true)); // site.url() return the full url if the second argument is true
 }
 for (const file of site.files) {
 urls.add(site.url(file.outputPath, true));
 }
});
site.use(modifyUrls({
 // Use the urls
})
This loop is executed for every url found in the html code. It should be moved outside this function and run only once. For example: ```js const urls = new Set<string>(); // Set is more performant than arrays site.process("*", (pages) => { url.clear(); // Clear on rebuild for (const page of pages) { urls.add(site.url(page.data.url, true)); // site.url() return the full url if the second argument is true } for (const file of site.files) { urls.add(site.url(file.outputPath, true)); } }); site.use(modifyUrls({ // Use the urls }) ```
iacore commented 2024年06月26日 06:44:01 +02:00 (Migrated from github.com)
Copy link

should still merge modify_urls.ts into this

should still merge modify_urls.ts into this

nice! Can I merge it?

nice! Can I merge it?
iacore commented 2024年06月26日 22:26:29 +02:00 (Migrated from github.com)
Copy link

new, new finding! Add this in documentation:

this plugin must be put after resolve_urls and relative_urls, or it will report false broken links. ideally, put it as the last plugin.

nice! Can I merge it?

you can merge it now.

new, new finding! Add this in documentation: this plugin must be put after resolve_urls and relative_urls, or it will report false broken links. ideally, put it as the last plugin. > nice! Can I merge it? you can merge it now.
iacore commented 2024年06月26日 22:40:57 +02:00 (Migrated from github.com)
Copy link

more ux

this plugin is great. while muffet will turn a blind eye to /a -> /a/, this plugin will not.

it also checks if files by site.copy is... i guess i found another bug?

the issue is, let's say i have a file a.md that is referenced in index.md as [a](./a.md).

i have site.copy('a.md').

i have site.use(resolve_urls()).

resolve_urls will rewrite the url to /a/index.html (wtf?)

maybe site.copy should auto call site.ignore

more ux this plugin is great. while muffet will turn a blind eye to `/a` -> `/a/`, this plugin will not. it also checks if files by `site.copy` is... i guess i found another bug? the issue is, let's say i have a file `a.md` that is referenced in `index.md` as `[a](./a.md)`. i have `site.copy('a.md')`. i have `site.use(resolve_urls())`. resolve_urls will rewrite the url to `/a/index.html` (wtf?) maybe site.copy should auto call site.ignore

resolve_urls doesn't replace urls for pages that don't exist.
If you copy a.md, you should have a.md in your dest folder.

resolve_urls doesn't replace urls for pages that don't exist. If you copy a.md, you should have a.md in your dest folder.

the issue is, let's say i have a file a.md that is referenced in index.md as a.

Okay, I just reproduced this issue. It's a bug, will fix it.

> the issue is, let's say i have a file a.md that is referenced in index.md as [a](./a.md). Okay, I just reproduced this issue. It's a bug, will fix it.

Sorry, I merged this PR without reviewing the code (I thought you only made my previous suggestions).
Why did you copy the code from modify_urls to this plugin?

Sorry, I merged this PR without reviewing the code (I thought you only made my previous suggestions). Why did you copy the code from modify_urls to this plugin?
iacore commented 2024年06月27日 19:32:40 +02:00 (Migrated from github.com)
Copy link

Why did you copy the code from modify_urls to this plugin?

modify_urls uses node.setAttribute while this plugin doesn't. might be faster.

> Why did you copy the code from modify_urls to this plugin? modify_urls uses `node.setAttribute` while this plugin doesn't. might be faster.

Ah, okay.
If this plugin is merged in Lume repo, maybe it's a good idea to move this logic to a external function shared by both plugins to remove duplicated code.

Ah, okay. If this plugin is merged in Lume repo, maybe it's a good idea to move this logic to a external function shared by both plugins to remove duplicated code.
iacore commented 2024年06月27日 20:07:33 +02:00 (Migrated from github.com)
Copy link

Ah, okay. If this plugin is merged in Lume repo, maybe it's a good idea to move this logic to a external function shared by both plugins to remove duplicated code.

maybe you can add a comment at the top of the file for this.

> Ah, okay. If this plugin is merged in Lume repo, maybe it's a good idea to move this logic to a external function shared by both plugins to remove duplicated code. maybe you can add a comment at the top of the file for this.
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lume/experimental-plugins!39
Reference in a new issue
lume/experimental-plugins
No description provided.
Delete branch "check_links"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?