Skip to content

Commit 8736eac

Browse files

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ OctoLinker is the easiest and best way to navigate between files and projects on
100100
### Sass
101101
- `@import`
102102

103+
### less
104+
- `@import`
105+
103106
### HTML
104107
- `<link rel="import" href="...">`
105108

lib/pattern-preset.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ export const presets = {
108108
],
109109
},
110110

111+
less: {
112+
pathSubstrings: ['.less'],
113+
githubClasses: [
114+
'type-less',
115+
'highlight-source-css-less',
116+
],
117+
},
118+
111119
html: {
112120
pathSubstrings: [
113121
'.html',

lib/plugins/less.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { CSS_IMPORT } from '../../packages/helper-grammar-regex-collection/index.js';
2+
import insertLink from '../insert-link';
3+
import preset from '../pattern-preset';
4+
import relativeFile from '../resolver/relative-file.js';
5+
6+
export default class Less {
7+
8+
static resolve({ path, target }) {
9+
return [
10+
relativeFile({ path, target }),
11+
];
12+
}
13+
14+
getPattern() {
15+
return preset('less');
16+
}
17+
18+
parseBlob(blob) {
19+
insertLink(blob.el, CSS_IMPORT, {
20+
pluginName: this.constructor.name,
21+
target: '$1',
22+
path: blob.path,
23+
});
24+
}
25+
}

test/plugins/less.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import assert from 'assert';
2+
import Less from '../../lib/plugins/less';
3+
4+
describe('Less', () => {
5+
const path = '/octo/dog.less';
6+
7+
it('resolves links', () => {
8+
assert.deepEqual(
9+
Less.resolve({ path, target: 'foo.less' }),
10+
[
11+
'{BASE_URL}/octo/foo.less',
12+
],
13+
);
14+
});
15+
});

0 commit comments

Comments
 (0)